I would like to use the SAS array statement to create 3 new variables(yes or no) from 48 variables that contain just 3 drug classes, Benzos, Opioids and Anticholinergics. So the 48 variables are listed as drugflag1-drugflag48.
The new variables 1-3 are Benzo_rc, Opioid_rc and Antichol. For variable Benzo, if drugflag1- drugflag48 has Benzo then the Variable Benzo_rc="Yes" if not Benzo_rc
Data Merged_data3;
Set Merged_data3;
array drugname $DrugFlag1-DrugFlag48;
do i = 1 to 48;
IF drugname[i]= BENZO THEN benzo_rc = 1; ELSE benzo_rc = 0;End;Run;
="No".
I have tried the following code but it is not working. Please, I need help.
... View more