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
  • why do you convert headache/breasttenderness to lowercase? It won't ever be equal to "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
Add a comment  | 

1 Answer 1

Reset to default 0

If 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;

本文标签: