Hi,
I need help in the following by group processing, such for the same USUBJID, and have AVAL=0 then i need the final output have flag='Y', if that is not the case then populate flag='N'.
data create;
input usubjid $ aval;
cards;
12 1
12 4
12 0
12 2
13 2
13 5
13 6
13 4
13 0
14 5
14 7
14 8
;
run;
proc sort data=create;
by usubjid aval;
run;
data check;
set create;
by usubjid aval;
if first.usubjid and aval=0 then flag="Y";
run;
This can be done using a RETAIN statement
data check;
set create;
by usubjid aval;
if first.usubjid and aval=0 then flagg="Y";
else flagg="N";
retain flag;
if first.usubjid then flag=flagg;
drop flagg;
run;
It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.