BookmarkSubscribeRSS Feed
mar0000
Obsidian | Level 7
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.

2 REPLIES 2
ChrisNZ
Tourmaline | Level 20

 So if encounter 1 has dates 10jan2019 and 30 jan2019, and encounter 2 has dates 25jan2020 and 20feb2020, is that still NEWVAR=2 ?

sas-innovate-white.png

Missed SAS Innovate in Orlando?

Catch the best of SAS Innovate 2025 — anytime, anywhere. Stream powerful keynotes, real-world demos, and game-changing insights from the world’s leading data and AI minds.

 

Register now

How to Concatenate Values

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 2 replies
  • 742 views
  • 0 likes
  • 3 in conversation