Hi,
I have dataset with four variables…..id, etcd ,stdtc, endtc
14615100010001 SCRN 2014-07-31 2014-08-05
14615100010001 COMB 2014-08-05 2014-11-13
14615100010001 1000394 2014-11-14 2014-11-17
14615100010001 SAFFU 2014-11-26 2014-12-23
14615100010001 SURVFU 2014-12-24 2015-04-28
14615100010003 SCRN 2015-02-19 2015-02-25
14615100010003 COMB 2015-02-25 2015-07-02
14615100010003 1000394 2015-07-03 2015-07-06
14615100010003 SURVFU 2015-08-12 2015-08-14
I want to write a query in such a way that I want to output the following
For every id, The difference between the ENDTC and STDTC of next record should not be greater then1.
If the difference in greater then 1, we should output those. Those highlighted in yellow are discrepancies and we should output those.
Can someone help on this….
Use lag function:
data check; set have; if lag(enddtc) - stdtc ne 1 then flag="Y"; run;
Use a data step w/ BY and RETAIN . An potentially the use of first. and last. logic.
Use lag function:
data check; set have; if lag(enddtc) - stdtc ne 1 then flag="Y"; run;
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 the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.
Find more tutorials on the SAS Users YouTube channel.