BookmarkSubscribeRSS Feed
Obsidian | Level 7

Hello - I'm trying to get a proc freq output that contains 3 columns (all patients, COPD=0, COPD=1) instead of running 2 procedures and coping the answers over by hand. Can you help?

proc freq order=freq; table race; run;
proc freq order=freq; table race*COPD; run;

Desired output:

             All     COPD=0    COPD=1





Also, is there a way to order by a certain column or will SAS always order by descending row sum?


You're probably better off switching from PROC FREQ to PROC TABULATE.  Here's some untested code:

proc tabulate data=have;
   class race copd;
   tables race, all copd;
Super User

If @Astounding's suggestion does not do what you want then please show us what you actually expect for out. Better would be to provide some example data in the form of a data step or use one of the SAS supplied data sets such as SASHELP.Class.


Plus you can make many tables with a single proc freq call such as

proc freq order=freq; 
  tables race race*COPD; 

Or if you want multiple tables with different options use multiple tables statements like

Proc freq order=freq;
   tables race;
   table race*copd/ chisqr;
Super User
Doesn't the second PROC FREQ generate what you want? There's a total column by default.
It may depend on how your data is structured but you haven't shared that information.


Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.


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
  • 3 replies
  • 1 like
  • 4 in conversation