data abcd;
input id date encounter;
cards;
1 09APR2012 1
1 11APR2012 1
1 26AUG2012 2
2 10MAY2015 1
2 15AUG2015 2
2 20AUG2015 2
2 02JAN2016 3
2 17MAR2016 4
3 12DEC2013 1
3 18JAN2014 2
4 09SEP2013 1
;
RUN;
I have this dataset that has ID, Date, and encounter. If the dates are within 30 days apart, the encounter remains the same encounter.
I want to say something like "if the person exists only once and has only one encounter, then newvar = 1"
I also want to say "if the person exists multiple times and only has three or less encounters AND those three encounters occur within the same year (365 days), then newvar2 = 1"
I also want to say "if the person exists multiple times and has three or more encounters AND those encounters occur within mutiple years, then newvar3 = 1"
I'm not entirely sure where to start.
So if encounter 1 has dates 10jan2019 and 30 jan2019, and encounter 2 has dates 25jan2020 and 20feb2020, is that still NEWVAR=2 ?
Please fix your data step, so that it creates correct data.
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.