- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
I need to calculate the total hh stay length for patient. below data example is for one patient's record. It includes start date, restart date, discharge date for each episode in three columns, and I needs to get stay length for all episodes. In this example, there are 3 episodes. 15-02-25 to 15-03-13, 15-03-23 to 15-04-07, 15-04-10 to 15-05-11. I'm confused how to deal with the restart_dt and I am struggled to get the total length for each patients in my dataset. Thanks for help if anyone has any ideas.
- Tags:
- SAS programming
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
So do you have SAS date values? Any manipulation works much better with those.
If not you have to tell which of those values is the year, which the month and which the day of the month so we can help you create date values.
It might help us to show exactly what result you are expecting.
Ideally you would post data as data step code that we can run pasted into a code box opened on the forum with either the </> or "running man" icons that appear above the message window. Or at least copied text pasted into one of the boxes. But we can't write code from a picture and very few of us are going to retype stuff from a picture.
Since you did not include any other information how do we know which values are to be consider for these calculations? With the word you are using like "discharge" one would expect at least a patient identifier so that w have some idea of what is going on. Without that, kind of requires mind-reading skills.
From that picture I have a very hard time getting this connection at all: 15-04-10 to 15-05-11.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Please explain the logic you are using to extract the reported results from the sample input data.
The hash OUTPUT method will overwrite a SAS data set, but not append. That can be costly. Consider voting for Add a HASH object method which would append a hash object to an existing SAS data set
Would enabling PROC SORT to simultaneously output multiple datasets be useful? Then vote for
Allow PROC SORT to output multiple datasets
--------------------------
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Where there is no re-start, you would just take an interval in days between two date values: intck(‘day’, start, discharge). Where there is a re-start, I suppose that would be their second visit, you would need to know what was their second discharge (“re-discharge”), then sum the two intervals calculated with the intck function: sum( intck(‘day’, start, discharge), intck(‘day’, re-start, re-discharge)).
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
https://communities.sas.com/t5/SAS-Programming/Fill-missing-values-with-the-previous-values/td-p/326...
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
The columns would need to be arranged in a better way. First take distinct non-missing values from each column in ascending order into a separate table. Then, for each table, create column Month = month(date). Re-merge columns by month. Finish by filling in missing values with last available value from the SAS post I shared previously. The resulting table will be much easier to work with.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Instead of re-Arranging the data, you should go back some steps an investigate how the dataset you have now was created, maybe intercepting in the process at an earlier stage makes it easier to solve the task.