BookmarkSubscribeRSS Feed
mtao
Calcite | Level 5
Hello,
Please see below is an example of the messy data I have. A member has records for mutiple hospitalizations; for seemingly one hospitalization, there were multiple rows of records with slightly different admission dates and discharge dates.

I hope to clean the data and get one record for one hospitalization. When there are mutiple rows for seemingly one hospitalization because of the overlaping time, create one record with earliest admission date and latest discharge date.

Raw data:

MemberID admission_date discharge_date
aaaa 9/11/2007 9/22/2007
aaaa 9/11/2007 9/26/2007

aaaa 10/11/2007 10/26/2007

aaaa 4/1/2008 4/14/2008
aaaa 4/7/2008 5/8/2008
aaaa 4/17/2008 4/28/2008

Hope to clean the data as

MemberID admission_date discharge_date
aaaa 9/11/2007 9/26/2007
aaaa 10/11/2007 10/26/2007
aaaa 4/1/2008 5/8/2008

I couldn't figure out a way to program this. Does anybody know? Thanks a lot.
2 REPLIES 2
sbb
Lapis Lazuli | Level 10 sbb
Lapis Lazuli | Level 10
Though not scientific, consider using a DATA step and a DO / END loop to generate one observation for each date within the range, then sort the observations in sequence and use the LAG function to compare adjacent observations, and if there is a gap of more than some determined length of days (using the INTCK function), then increment a counter. Lastly, use PROC SUMMARY to generate a MIN/MAX variable for each hospitalization.

Scott Barry
SBBWorks, Inc.
sfleming
Calcite | Level 5
There was actually a paper at this year's Global Forum that covered a very similar topic.

http://support.sas.com/resources/papers/proceedings09/079-2009.pdf

I hope you can find something in here to help.

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!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

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