BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
sas1011
Calcite | Level 5

Hello,

 

I have a data set that has clinical member information with discharge dates for each member. This dataset also has the same member(identified by the member_id) that have multiple rows with different discharge dates if they were re-admitted.

 

I want to be able to get one row for each member ID with a new column(s) for the different discharge dates.

 

Sample data(HAVE):

 

 

Member_ID                               Discharge_date                                    Hospital

 

1                                                  11/20/2019                                            ABC

1                                                  12/03/2019                                            ABC

2                                                  11/22/2019                                            XYZ

3                                                  11/20/2019                                            ABC

4                                                  10/30/2019                                            JKL

4                                                  11/15/2019                                            JKL

 

 

Result(NEED):

 

Member_ID                               Discharge_date          Discharge_date2                          Hospital

 

1                                                  11/20/2019                    12/03/2019                                ABC

2                                                  11/22/2019                            .                                         XYZ

3                                                  11/20/2019                            .                                         ABC

4                                                  10/30/2019                     11/15/2019                               JKL

                                                                                                                       

 

 

 

I'm not able to wrap my mind around how to get this done.

 

It sounds like it might be an easy solution for some of the experts in this community.

 

Thanks for the help.

1 ACCEPTED SOLUTION

Accepted Solutions
novinosrin
Tourmaline | Level 20


data have;
input Member_ID                               Discharge_date  :mmddyy10.                          Hospital $;
format Discharge_date mmddyy10.;
cards;
1                                                  11/20/2019                                            ABC
1                                                  12/03/2019                                            ABC
2                                                  11/22/2019                                            XYZ
3                                                  11/20/2019                                            ABC
4                                                  10/30/2019                                            JKL
4                                                  11/15/2019                                            JKL
;

proc transpose data=have out=want(drop=_name_) prefix=Discharge_date;
by member_id hospital;
var Discharge_date;
run;

View solution in original post

2 REPLIES 2
novinosrin
Tourmaline | Level 20


data have;
input Member_ID                               Discharge_date  :mmddyy10.                          Hospital $;
format Discharge_date mmddyy10.;
cards;
1                                                  11/20/2019                                            ABC
1                                                  12/03/2019                                            ABC
2                                                  11/22/2019                                            XYZ
3                                                  11/20/2019                                            ABC
4                                                  10/30/2019                                            JKL
4                                                  11/15/2019                                            JKL
;

proc transpose data=have out=want(drop=_name_) prefix=Discharge_date;
by member_id hospital;
var Discharge_date;
run;
sas1011
Calcite | Level 5

Thank you. This worked. 

 

I never used proc transpose until now - thats why it never occured to me.

 

Thanks

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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
  • 685 views
  • 0 likes
  • 2 in conversation