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.
Don't miss out on SAS Innovate - Register now for the FREE Livestream!
Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.
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.