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;
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
Still thinking about your presentation idea? The submission deadline has been extended to Friday, Nov. 14, at 11:59 p.m. ET.
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.