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.
Available on demand!
Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.
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.
Select SAS Training centers are offering in-person courses. View upcoming courses for: