BookmarkSubscribeRSS Feed
Samsami
Calcite | Level 5

Hello,

how to calculate the length of stay for a group of patients using SQL query, I do have a table which contain Patient Id, Date of admission, date of discharge.

Appreciate your help.

2 REPLIES 2
ChrisBrooks
Ammonite | Level 13

This should be straightforward because SAS dates are just formatted numbers so subtracting one from the other should give you the length of stay. However if you want something more precise you'll have to give us more details - check out this post for how to frame your question so we can help you better (in particular we'd need some sample data). https://communities.sas.com/t5/SAS-Support-Communities/How-to-ask-a-good-question-and-receive-a-fast...

PGStats
Opal | Level 21

If your dates are SAS dates then the SQL column expression should be

 

intck("day", admissionDate, dischargeDate) + 1 as lengthOfStay

 

+ 1 is assuming that a patient admitted and discharged on the same day will have a length of stay of 1 day.

PG

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

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
  • 1654 views
  • 0 likes
  • 3 in conversation