Help using Base SAS procedures

How to combine rows of data in SAS

Accepted Solution Solved
Reply
Regular Learner
Posts: 1
Accepted Solution

How to combine rows of data in SAS

I am trying to combine/collapse data to make it easier to run statistics on, but am having trouble on how to combine the data.

I was given billing data, and therefore patients can be billed multiple times for the same procedure using different billing codes.

I am trying to combine rows of data into a single row based on a patient's MRN and their date of surgery regardless of their billing codes (as I have recoded all the billing codes into bundles based on the procedure type).

 

i.e.

 

MRN      DOB       Date of Surgery    Procedure Code

12345    1/1/11    July 1, 2017          12345

12345    1/1/11    July 1, 2017          12345

67890    2/2/22    July 2, 2017          12345

67890   2/2/22     July 3, 2017           23456

45678   3/3/33     July 4, 2017           567890

45678   3/3/33     July 4, 2017           567890

45678   3/3/33     July 4, 2017           567890

 

 

In the above example, I woul want it to be collapsed to the following:

MRN      DOB       Date of Surgery    Procedure Code

12345    1/1/11    July 1, 2017          12345

67890    2/2/22    July 2, 2017          12345

67890   2/2/22     July 3, 2017           23456

45678   3/3/33     July 4, 2017           567890

 

I have tried the 

PROC MEANS NWAY;
  CLASS ;
  VAR ;
  OUTPUT OUT= MEAN= STD= N=;
RUN;

 But this did not work out.

 

Thank you


Accepted Solutions
Solution
‎08-21-2017 02:09 PM
Frequent Contributor
Posts: 76

Re: How to combine rows of data in SAS

 

TRY THIS CODE

 

proc sort data=have out=want nodup;by MRN;run;

View solution in original post


All Replies
Super User
Posts: 18,603

Re: How to combine rows of data in SAS

Is that the PROC MEANS code you submitted? If not, please post the exact code. 

 

Look at PROC SORT with the NODUPKEY option. 

 

 

Solution
‎08-21-2017 02:09 PM
Frequent Contributor
Posts: 76

Re: How to combine rows of data in SAS

 

TRY THIS CODE

 

proc sort data=have out=want nodup;by MRN;run;

☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 2 replies
  • 161 views
  • 2 likes
  • 3 in conversation