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
race1
race2
race3
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;
run;
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;
run;
Or if you want multiple tables with different options use multiple tables statements like
Proc freq order=freq; tables race; table race*copd/ chisqr; run;
Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.
If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website.
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.