Hi,
I have hospital admissions data for a cohort of children. Some children have only one admission, while others have many. Each admission is a new row. So I can have multiple rows for each child, and each row is a new hospital admission.
I want to count the days between each admission for each child.
I'm using SAS9.4 1M5
Many thanks for your help.
A very important question: is the admission date a SAS date valued variable, meaning numeric with a format like DATE9. or MMDDYY10. or similar applied to it?
If not then we need to know exactly how your date values are stored as that seriously affects the next steps.
And is the value actually a date or does it have a time component as well? Some folks seem not to know the difference and we get questions about "dates" like 01JAN2020:17:23:15, which has TIME and different approach would be needed.
If the date variable is a SAS date value then something like:
Proc sort data=have; by childid date; run; data want; set have; by childid; days= dif(date); if first.childid then days = 0; run;
Days will have the number days between visits for those children with multiple visits and with 0 for the first visit by any child.
A very important question: is the admission date a SAS date valued variable, meaning numeric with a format like DATE9. or MMDDYY10. or similar applied to it?
If not then we need to know exactly how your date values are stored as that seriously affects the next steps.
And is the value actually a date or does it have a time component as well? Some folks seem not to know the difference and we get questions about "dates" like 01JAN2020:17:23:15, which has TIME and different approach would be needed.
If the date variable is a SAS date value then something like:
Proc sort data=have; by childid date; run; data want; set have; by childid; days= dif(date); if first.childid then days = 0; run;
Days will have the number days between visits for those children with multiple visits and with 0 for the first visit by any child.
thanks Ballardw,
date is DDMMYY10.
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 25. Read more here about why you should contribute and what is in it for you!
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.