BookmarkSubscribeRSS Feed
sandhya88
Calcite | Level 5
Data have;
input id $ test$ visit result;
1 ALT 1 25
1 ALT 2 35
1 ALT 3 35
2 ALT 1 20
3 AST 1 20
3 AST 2 20;
run;

Data want;
input id$ test$ visit result flg$;
1 ALT 1 25 .
1 ALT 2 35 .
1 ALT 3 35 Y
2 ALT 1 20 Y
3 AST 1 20 .
3 AST 2 20 Y;
run;
1 REPLY 1
PaigeMiller
Diamond | Level 26
data want;
    set have;
    by id;
    if last.id then flg='Y'; else flg='.';
run;

 

 

If I may be so bold, setting FLG to 'Y' or '.' is not such a good idea; setting FLG to numeric 0 or 1 is not only easier to type, but has other benefits as well (such as computing proportions that are flagged can be done by computing a mean).

--
Paige Miller

sas-innovate-white.png

Register Today!

Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.

Register now!

How to Concatenate Values

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 1 reply
  • 414 views
  • 0 likes
  • 2 in conversation