BookmarkSubscribeRSS Feed
Q1983
Lapis Lazuli | Level 10

data have;

input id Cd $ flg $ DATE DATE9.;

format date date9.;

datalines;

 

11 chg b 13apr2019

11 chg i 11apr2019  /*show*/

11 chg e 6apr2019 /*show*/

11 chg b 5apr2019

11 add d 4apr2019  /*show*/

11 chg y 1apr2019

;run;

 

I want to select the last instance of the ( flg = d or 11 add d 4apr2019)

I want to select the first instance after the row moved from a flg = d to an e or 11 chg e 6apr2019)

I want to then select the first instance where the row moved from the flg = e to something else.  So in this case I want to show 11 chg i 11apr2019

 

1 REPLY 1
Shmuel
Garnet | Level 18

It is not clear what are the rules for selection.

What do you mean by "...where the row moved from the flg = e to something else" ?

 

make your selection by WHERE clause:

data want;
 set have;
      where flag="D" or ...;  /* combine your conditions */
run;
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
  • 640 views
  • 0 likes
  • 2 in conversation