BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
analyst_work
Obsidian | Level 7

I need to limit one admission per year, there can be multiple admissions for that one patient. I want to look across all admissions and then select one admission per year. Thank you!

 

Patient CAdm 114-Jan-16Include first admission
Patient CAdm 26-May-17Include (more than 365 days)
Patient CAdm 35-Jun-17Exclude (less than 365 days from Adm 2)
Patient DAdm 114-Jan-16Include first admission
Patient DAdm 26-Jan-17Exclude (less than 365 days from Adm 1)
Patient DAdm 35-Jun-17Include (more than 365 days from Adm 1)
1 ACCEPTED SOLUTION

Accepted Solutions
novinosrin
Tourmaline | Level 20

Hi @analyst_work  Thank you

 



data have;
infile cards truncover;
input patient & $20. adm & $6. date :date9.;*  out_date :date9.;
format date date9.  ;*out_date date9.;
cards;
Patient C	Adm 1	14-Jan-16	Include first admission
Patient C	Adm 2	6-May-17	Include (more than 365 days)
Patient C	Adm 3	5-Jun-17	Exclude (less than 365 days from Adm 2)
Patient D	Adm 1	14-Jan-16	Include first admission
Patient D	Adm 2	6-Jan-17	Exclude (less than 365 days from Adm 1)
Patient D	Adm 3	5-Jun-17	Include (more than 365 days from Adm 1)
;




data want;
set have;
by patient;
retain d;
if first.patient then do; d=date;f=1;end;
else if intck('day',d,date)>365 then do;
d=date;
f=1;
end;
if f;
drop f d;
run;

View solution in original post

6 REPLIES 6
PeterClemmensen
Tourmaline | Level 20

You have two different date variables here. What dates are to be considered? The to date from adm1 and the from date from adm2?

analyst_work
Obsidian | Level 7
Updated the table above. Thanks!
novinosrin
Tourmaline | Level 20

Hi @analyst_work   Please review 

 

Patient D Adm 1 12-Jan-16 14-Jan-16 Include first admission
Patient D Adm 2 6-May-17 6-Jan-17 Exclude (less than 365 days from Adm 1)

 

How is the number of days between  14-Jan-16 and 6-May-17 is less than 365?

 

EDITED: Please ignore this post

analyst_work
Obsidian | Level 7
Please see updated table above. Thanks!
novinosrin
Tourmaline | Level 20

Hi @analyst_work  Thank you

 



data have;
infile cards truncover;
input patient & $20. adm & $6. date :date9.;*  out_date :date9.;
format date date9.  ;*out_date date9.;
cards;
Patient C	Adm 1	14-Jan-16	Include first admission
Patient C	Adm 2	6-May-17	Include (more than 365 days)
Patient C	Adm 3	5-Jun-17	Exclude (less than 365 days from Adm 2)
Patient D	Adm 1	14-Jan-16	Include first admission
Patient D	Adm 2	6-Jan-17	Exclude (less than 365 days from Adm 1)
Patient D	Adm 3	5-Jun-17	Include (more than 365 days from Adm 1)
;




data want;
set have;
by patient;
retain d;
if first.patient then do; d=date;f=1;end;
else if intck('day',d,date)>365 then do;
d=date;
f=1;
end;
if f;
drop f d;
run;
ballardw
Super User

@analyst_work wrote:

I need to limit one admission per year, there can be multiple admissions for that one patient. I want to look across all admissions and then select one admission per year. Thank you!

 

Patient C Adm 1 14-Jan-16 Include first admission
Patient C Adm 2 6-May-17 Include (more than 365 days)
Patient C Adm 3 5-Jun-17 Exclude (less than 365 days from Adm 2)
Patient D Adm 1 14-Jan-16 Include first admission
Patient D Adm 2 6-Jan-17 Exclude (less than 365 days from Adm 1)
Patient D Adm 3 5-Jun-17 Include (more than 365 days from Adm 1)

Any other rules? Is this supposed to be a random selection? First within period?

 

And do you actually have SAS date values or are your values currently character values that resemble dates?

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
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
  • 6 replies
  • 784 views
  • 0 likes
  • 4 in conversation