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

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

1 ACCEPTED SOLUTION

Accepted Solutions
TarunKumar
Pyrite | Level 9

 

TRY THIS CODE

 

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

View solution in original post

2 REPLIES 2
Reeza
Super User

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

 

Look at PROC SORT with the NODUPKEY option. 

 

 

TarunKumar
Pyrite | Level 9

 

TRY THIS CODE

 

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

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
  • 882 views
  • 2 likes
  • 3 in conversation