I have a variable ("medical") with character values that are various medical conditions. For example, in one observation "medical"=
"Arthritis/Joint Pain,Chronic Pain,Depression,Insomnia or other sleep disorder,Nausea"
I want to create a new variable for each medical condition, and have SAS input a "1" whenever that medical condition is among the values in the variable. Using the observation above, the desired output would be:
arthritis=1
chron_pn=1
depression=1
insomnia=1
nausea=1
When I used the code below, the syntax executes correctly, but ONLY if the medical condition (e.g. Anxiety) is the ONLY value in the variable. In other words, the syntax only works correct when "medical"="anxiety", but not when "medical"="Anxiety,Depression,Chronic Pain"
IF medical IN("Anxiety") THEN anxiety=1;
ELSE IF medical IN("Arthritis/Joint Pain") THEN arthritis=1;
ELSE IF medical IN("Chronic Pain") THEN chron_pn=1;
ELSE IF medical IN("Depression") THEN depression=1;
ELSE IF medical IN("Epilepsy or other seizure disorder") THEN seizures=1;
ELSE IF medical IN("Nausea") THEN nausea=1;
ELSE IF medical IN("PTSD") THEN ptsd=1;
ELSE IF medical IN("Other reasons (please describe)") THEN other=1;
ELSE IF medical IN("Allergies or Asthma") THEN allergies=1;
ELSE IF medical IN("Insomnia or other sleep disorder") THEN sleep=1;
ELSE IF medical IN("Migraine, cluster, tension headaches (which kind)") THEN ha=1;
ELSE IF medical IN("COPD / other lung condition (please specify)") THEN resp=1;
ELSE IF medical IN("Alzheimer's Disease") THEN alz_dz=1;
ELSE IF medical IN("Multiple Sclerosis") THEN ms=1;
ELSE IF medical IN("Parkinson's Disease") THEN pd=1;
ELSE IF medical IN("Cancer (which kind)") THEN cancer=1;
Thanks for the assistance!
... View more