I created dataset temp just to have some data to illustrate my point. The input statement tells SAS what to read in from the data lines I will be providing and the datalines statement start off the listing of the raw data.
Your code would have only one DATA step and should look similar to this:
data Final_drug_counts;
set Final_drug;
by seqn;
if first.seqn then count=0;
array drugs {*} DrugID:;
do i = 1 to dim(drugs);
count + (drugs[i]=40);
end;
run;
Your other variables will remain in the dataset, unchanged.
... View more