DATA Step, Macro, Functions and more

How to save proc freq result as a table?

Accepted Solution Solved
Reply
Frequent Contributor
Posts: 99
Accepted Solution

How to save proc freq result as a table?

This should be pretty much straightforward but I can't get it work even after reading through the documentation...

 

/*save the var1 freq table*/
proc freq data=have order=freq ;
output out=var1_freq;
tables var1/list missing;  
run;

/*save the two freq tables*/
proc freq data=have order=freq ;
output out=var1_freq var1var2_freq;
tables var1 var1*var2/list missing;  
run;


Accepted Solutions
Solution
‎04-06-2017 01:25 AM
Super User
Posts: 17,811

Re: How to save proc freq result as a table?

Read the warnings in your log. Always. 

They state that a statistic is required. 

 

OUT on the TABLES statement is used to capture the frequencies. 

OUTPUT statement is used to capture test statistics. 

ODS OUTPUT is a different way to keep the counts. 

 

See the example below. 

 

Proc freq data=SASHELP.class;

tables sex / out = freqs chisq;

output out= stats chisq;

ODS onewayFreq= frreqs2;

run;

View solution in original post


All Replies
Contributor
Posts: 35

Re: How to save proc freq result as a table?

 

 

proc freq data=have order=freq ;
tables var1/list missing out=var1_freq;
run;

/*save the two freq tables*/
proc freq data=have order=freq ;
tables var1 var1*var2/list missing out=var2_freq;
run;

Contributor
Posts: 56

Re: How to save proc freq result as a table?

proc freq data=have;
tables var1/out=var1_data;
tables var1*var2/out=var2_data;
run;
Frequent Contributor
Posts: 99

Re: How to save proc freq result as a table?

But it seems that the output doesn't include the cumulative frequency and cumulative percent. Is it possible to get these variables as well?
Super User
Posts: 17,811

Re: How to save proc freq result as a table?

RTM for the options on the TABLES statement that control the output. 

Solution
‎04-06-2017 01:25 AM
Super User
Posts: 17,811

Re: How to save proc freq result as a table?

Read the warnings in your log. Always. 

They state that a statistic is required. 

 

OUT on the TABLES statement is used to capture the frequencies. 

OUTPUT statement is used to capture test statistics. 

ODS OUTPUT is a different way to keep the counts. 

 

See the example below. 

 

Proc freq data=SASHELP.class;

tables sex / out = freqs chisq;

output out= stats chisq;

ODS onewayFreq= frreqs2;

run;

Frequent Contributor
Posts: 99

Re: How to save proc freq result as a table?

I see, thanks for the explanation Reeza.
☑ This topic is SOLVED.

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

Discussion stats
  • 6 replies
  • 207 views
  • 1 like
  • 4 in conversation