BookmarkSubscribeRSS Feed
blacklucas1
Calcite | Level 5

Hi all - been struggling with this for a little bit and it seems incredibly simple. I've tried a simple left join but it didn't give me the results I was hoping for.

I have a dataset of hospitalizations containing patient identification numbers and various other characteristics.

in the dataset, we have index events hospitalizations for a certain procedure + readmission hospitalizations. Thus, a specific patient ID number has 2 rows of data if they were readmitted (with the latter having readmission=1 and readmitdiagnosis. Values for these variables are null in the index hospitalization row.

How can I collapse these rows so each patient just has one row containing all of their data + readmission, readmitdiagnosis from the latter line?

 

Thank you in advance for the help.

2 REPLIES 2
ed_sas_member
Meteorite | Level 14

Hi @blacklucas1 

 

Welcome to the community!

Could you please post sample data using datalines as well as the desired output?

Thank you,

 

ballardw
Super User

@blacklucas1 wrote:

Hi all - been struggling with this for a little bit and it seems incredibly simple. I've tried a simple left join but it didn't give me the results I was hoping for.

I have a dataset of hospitalizations containing patient identification numbers and various other characteristics.

in the dataset, we have index events hospitalizations for a certain procedure + readmission hospitalizations. Thus, a specific patient ID number has 2 rows of data if they were readmitted (with the latter having readmission=1 and readmitdiagnosis. Values for these variables are null in the index hospitalization row.

How can I collapse these rows so each patient just has one row containing all of their data + readmission, readmitdiagnosis from the latter line?

 

Thank you in advance for the help.


Before going too far down this path you should consider definition of "readmission" and carefully share that. One concern is that a patient may have multiple readmissions and how to collapse 2 records, as described, will likely have a very poor result for someone with 2, 3, 4 or more readmissions.

 

Which is run reason to provide example data and what the resulting output should be as @ed_sas_member suggests.

 

Another bit might be describe what you expect to use that "collapsed" data for. It may well be possible to use your current data without bodging things together.

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

Mastering the WHERE Clause in PROC SQL

SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 2 replies
  • 350 views
  • 0 likes
  • 3 in conversation