Help using Base SAS procedures

Manipulating proc freq output

Accepted Solution Solved
Reply
Contributor
Posts: 71
Accepted Solution

Manipulating proc freq output

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    


Accepted Solutions
Solution
‎09-26-2011 09:46 AM
Contributor
Posts: 71

Re: Manipulating proc freq output

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


All Replies
PROC Star
Posts: 7,471

Manipulating proc freq output

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;

Contributor
Posts: 71

Manipulating proc freq output

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!

Solution
‎09-26-2011 09:46 AM
Contributor
Posts: 71

Re: Manipulating proc freq output

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;

Super User
Super User
Posts: 7,039

Manipulating proc freq output

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 ;

🔒 This topic is solved and locked.

Need further help from the community? Please ask a new question.

Discussion stats
  • 4 replies
  • 207 views
  • 6 likes
  • 3 in conversation