admin管理员组文章数量:1416642
I am trying to remove the "Don't know/refuse" for the headache and breasttenderness variable but all the values for the breasttenderness_num and headache_num are missing. Below is the code that I am using to remove the "don't know/refuse" level and convert the character pms symptom variables to numeric. there are 4 levels for the symptom variables "Not at all", "Mild", "Moderate", "Severe", "Don't know/refuse". Please let me know if you need any additional info.
```
data temp;
set pms.edc_data;
headache = strip(lowcase(headache));
breasttenderness = strip(lowcase(breasttenderness));
if headache = "Don't know/refuse" then headache = "";
if breasttenderness = "Don't know/refuse" then breasttenderness = "";
array char_vars {*} bloating breasttenderness dizzy headache hotflashes
heart_palpitations nausea swelling_extremities acne diarrhea_constipation fatigue
abdominal_cramping lower_backpain food_cravings appetite_change insomnia confusion
fetfulness anxiety irritability emotional_hypersensitivity mood_swings depression
cry anger alone;
array num_vars {*} bloating_num breasttenderness_num dizzy_num headache_num
hotflashes_num heart_palpitations_num nausea_num swelling_extremities_num acne_num
diarrhea_constipation_num fatigue_num abdominal_cramping_num lower_backpain_num
food_cravings_num appetite_change_num insomnia_num confusion_num fetfulness_num
anxiety_num irritability_num emotional_hypersensitivity_num mood_swings_num
depression_num cry_num anger_num alone_num;
do i = 1 to dim(char_vars);
char_vars{i} = strip(char_vars{i});
if char_vars{i} ne "" then
num_vars{i} = input(put(char_vars{i}, $severity_fmt.), best32.);
else if char_vars{i} = "" then
num_vars{i} = .;
end;
drop i;
run;
```
I am trying to remove the "Don't know/refuse" for the headache and breasttenderness variable but all the values for the breasttenderness_num and headache_num are missing. Below is the code that I am using to remove the "don't know/refuse" level and convert the character pms symptom variables to numeric. there are 4 levels for the symptom variables "Not at all", "Mild", "Moderate", "Severe", "Don't know/refuse". Please let me know if you need any additional info.
```
data temp;
set pms.edc_data;
headache = strip(lowcase(headache));
breasttenderness = strip(lowcase(breasttenderness));
if headache = "Don't know/refuse" then headache = "";
if breasttenderness = "Don't know/refuse" then breasttenderness = "";
array char_vars {*} bloating breasttenderness dizzy headache hotflashes
heart_palpitations nausea swelling_extremities acne diarrhea_constipation fatigue
abdominal_cramping lower_backpain food_cravings appetite_change insomnia confusion
fetfulness anxiety irritability emotional_hypersensitivity mood_swings depression
cry anger alone;
array num_vars {*} bloating_num breasttenderness_num dizzy_num headache_num
hotflashes_num heart_palpitations_num nausea_num swelling_extremities_num acne_num
diarrhea_constipation_num fatigue_num abdominal_cramping_num lower_backpain_num
food_cravings_num appetite_change_num insomnia_num confusion_num fetfulness_num
anxiety_num irritability_num emotional_hypersensitivity_num mood_swings_num
depression_num cry_num anger_num alone_num;
do i = 1 to dim(char_vars);
char_vars{i} = strip(char_vars{i});
if char_vars{i} ne "" then
num_vars{i} = input(put(char_vars{i}, $severity_fmt.), best32.);
else if char_vars{i} = "" then
num_vars{i} = .;
end;
drop i;
run;
```
Share
Improve this question
asked Feb 2 at 21:41
John MathewsJohn Mathews
631 silver badge5 bronze badges
1
|
1 Answer
Reset to default 0If you convert the text to lowercase.
headache = strip(lowcase(headache));
It will no longer have any upper case letters. Try
if headache = "don't know/refuse" then headache = " ";
What is the definition of the FORMAT that you are using?
Why don't you instead define an INFORMAT so you can use an INPUT() statement directly on the text values?
num_vars[i] = input(char_vars[i], severity_infmt.);
Plus informats allow the UPCASE option so you can make them work on mixed case text without having to fix the text first. You could even set the other category to trigger an error.
proc format ;
invalue severity_infmt (upcase)
"NOT AT ALL"=0
"MILD" =1
"MODERATE" =2
"SEVERE" =3
"DON'T KNOW/REFUSE"=.
other = _error_
;
run;
本文标签:
版权声明:本文标题:large data - What is the problem when I am trying to remove "Don't knowrefuse" level in SAS - Stack Ov 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745255550a2650076.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
"Don't know/refuse"
. Also you didn't specify what's your$severity_fmt.
, does it contain lowercase values or not? – Nickolay Commented Feb 2 at 22:55