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

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    

1 ACCEPTED SOLUTION

Accepted Solutions
HyunJee
Fluorite | Level 6

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;

View solution in original post

4 REPLIES 4
art297
Opal | Level 21

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;

HyunJee
Fluorite | Level 6

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 Smiley Happy always helpful!

HyunJee
Fluorite | Level 6

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;

Tom
Super User Tom
Super User

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 ;

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

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
  • 4 replies
  • 1959 views
  • 6 likes
  • 3 in conversation