I created some proc freq table of diagnosis codes by patient. In the output, the tables have the patient="patient name" listed at the top of every table. Is there any way to create a table with the patient name as a column in the frequency table?
so instead of being formatted as such:
patient
diagnosis frequency percent
would be like this instead:
patient diagnosis frequency percent
So I figured out on possible option. I wanted to post the answer I had come to. Create a dataset of the frequencies. This will give what I was wanting above. Works great too.
proc freq data=dataset noprint;
tables diagnosis*patient/norow nocol nopercent out = freq_pt_dx;run;
You didn't provide the code you were using, sample data, and/or the result you want to obtain. It sounds like you are currently using patient as a by variable and simply want to include it in your tables statement. e.g.,
proc freq data=sashelp.class;
tables name*age;
run;
instead of:
proc freq data=sashelp.class;
tables age;
by name;
run;
Sorry about that Art. I did use this code:
proc freq data=sashelp.class;
tables age;
by name;
But I had so many names that I could manipulate the outputed data like I had wanted.
I found that if I created a dataset of the frequencies of age*name, the dataset created was much more manageable in excel.
Thank you for your help and input always helpful!
So I figured out on possible option. I wanted to post the answer I had come to. Create a dataset of the frequencies. This will give what I was wanting above. Works great too.
proc freq data=dataset noprint;
tables diagnosis*patient/norow nocol nopercent out = freq_pt_dx;run;
As Art says add PATIENT to your TABLES statement. If you want it as a list then use the LIST option. Otherwise you will get a grid with #rows equal to the number of patients and #cols equal to the number of categories.
TABLES patient*diagnosis / list ;
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!
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.