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 ;

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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