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-2026-white.png



April 27 – 30 | Gaylord Texan | Grapevine, Texas

Registration is open

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!

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
  • 686 views
  • 0 likes
  • 2 in conversation