Hi
I have the below data set and I would like to pick up the mth_end_dt when SOR from 1 to any number.
data test;
informat MTH_END_DT date9.;
input CLNT_NO MTH_END_DT SOR;
format MTH_END_DT date9.;
cards;
1 31-Mar-14 1
1 30-Apr-14 1
1 31-May-14 2
1 30-Jun-14 2
1 31-Jul-14 3
1 31-Aug-14 3
1 30-Sep-14 3
1 31-Oct-14 3
1 30-Nov-14 1
1 31-Dec-14 3
1 31-Jan-15 3
1 28-Feb-15 6
;
run;
Help me
Thanks
maybe this what you want
data want ;
set test;
prev=lag(sor);
if prev=1 and sor ~=1;
drop prev;
run;
Can you explian better what you want to do? Could you give example of your desired output?
maybe this what you want
data want ;
set test;
prev=lag(sor);
if prev=1 and sor ~=1;
drop prev;
run;
Hi @umesh1,
If your real data contain more than one client, you may want to amend the IF condition in @mohamed_zaki's data step as shown below. Otherwise the first observation of a client might be selected because the previous client's last observation had SOR=1.
if prev=1 and sor ~=1 and clnt_no=lag(clnt_no);
However, this modification would be redundant if the first observation of each client had SOR=1.
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 save with the early bird rate—just $795!
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.