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.
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
Still thinking about your presentation idea? The submission deadline has been extended to Friday, Nov. 14, at 11:59 p.m. ET.
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.
Ready to level-up your skills? Choose your own adventure.