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
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;
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!
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.