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;
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 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.
Ready to level-up your skills? Choose your own adventure.