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-white.png

Special offer for SAS Communities members

Save $250 on SAS Innovate and get a free advance copy of the new SAS For Dummies book! Use the code "SASforDummies" to register. Don't miss out, May 6-9, in Orlando, Florida.

 

View the full agenda.

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

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