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 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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