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
Is that the PROC MEANS code you submitted? If not, please post the exact code.
Look at PROC SORT with the NODUPKEY option.
TRY THIS CODE
proc sort data=have out=want nodup;by MRN;run;
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.
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.
Ready to level-up your skills? Choose your own adventure.