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 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 16. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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