Hello @Sam1010 and welcome to the SAS Support Communities!
So, basically, each of the possible combinations of the three drug classes corresponds to one value of the new variable. Then I would also define the cases "none of the three" and "only ACEI and BB" (the latter occurs for patient no. 5; how about denoting this combination as "Double_AB"?) and use the CHOOSEC function:
data have;
input Patient_ID (Drug1-Drug7) ($);
cards;
1 Statin Statin BB . ACEI . Statin
2 . BB . BB BB . .
3 Statin . BB . . BB .
4 ACEI Statin . ACEI . . ACEI
5 . ACEI BB . . . .
6 Statin . . Statin . Statin .
7 BB . . . . . .
;
data want;
set have;
array d[*] drug:;
length Total_Med $12;
Total_Med=choosec(1 + ('ACEI' in d) + 2*('BB' in d) + 4*('Statin' in d),
' ','ACEI alone','BB alone','Double_AB???','Statin alone','Double_SA','Double_SB','Triple');
run;
The first argument of the CHOOSEC function is a number in {1, 2, ..., 8} and uniquely determines the combination (remember the binary number system). The subsequent strings describe these combinations.