Programming the statistical procedures from SAS

outputting frequencies into one dataset

Occasional Contributor
Posts: 17

outputting frequencies into one dataset

I would please like help trying to export these frequencies into one big table, instead of 4 seperate tables.  Is there a way to do this in SAS.  Any help would be greatly appreciated. 


proc freq data=M;
Tables (sex newrace livingage&year. risk;



Super User
Posts: 20,735

Re: outputting frequencies into one dataset

Posted in reply to beverlyobeng

If it's all one way freqs this the way I do it:


/*This code is an example of how to generate a table with 
Variable Name, Variable Value, Frequency, Percent, Cumulative Freq and Cum Pct
No macro's are required
Use Proc Freq to generate the list, list variables in a table statement if only specific variables are desired
Use ODS Table to capture the output and then format the output into a printable table.

*Run frequency for tables;
ods table onewayfreqs=temp;
proc freq data=sashelp.class;
	table sex age;

*Format output;
data want;
length variable $32. variable_value $50.;
set temp;
Variable=scan(table, 2);


keep variable variable_value frequency percent cum:;
label variable='Variable' 
	variable_value='Variable Value';

proc print data=want(obs=20) label;

Occasional Contributor
Posts: 17

Re: outputting frequencies into one dataset

thank you this was extremely helpful
Ask a Question
Discussion stats
  • 2 replies
  • 2 in conversation