BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
GS2
Obsidian | Level 7 GS2
Obsidian | Level 7

Hello,

 

I have the following proc freq:

 

Frequency
Col Pct
Table of x by z
x z
Partial Total
Complete
127
63.50
127
 
Other
73
36.50
73
 
Total
200
200

 

Is it possible to output the "Complete" frequency (127) and percent (63.50) and into a data set? Thank you

1 ACCEPTED SOLUTION

Accepted Solutions
Reeza
Super User
Look at the OUT option on the TABLE statement.

proc freq data=sashelp.class;
table age*sex / out=want outpct;
run;

It's also the first example in the documentation here:
https://documentation.sas.com/?docsetId=procstat&docsetTarget=procstat_freq_examples01.htm&docsetVer...

And specific documentation on the OUT statement is here:
https://documentation.sas.com/?docsetId=procstat&docsetVersion=9.4&docsetTarget=procstat_freq_syntax...

View solution in original post

2 REPLIES 2
Reeza
Super User
Look at the OUT option on the TABLE statement.

proc freq data=sashelp.class;
table age*sex / out=want outpct;
run;

It's also the first example in the documentation here:
https://documentation.sas.com/?docsetId=procstat&docsetTarget=procstat_freq_examples01.htm&docsetVer...

And specific documentation on the OUT statement is here:
https://documentation.sas.com/?docsetId=procstat&docsetVersion=9.4&docsetTarget=procstat_freq_syntax...
ballardw
Super User

It usually helps to show the code you are using so we can post code suggestions.

 

Proc freq will create output data sets several ways. One is to add an OUT=datasetname option to the tables statement. would require an OUTPCT option to get the percents. The OUT= option only will have result for a single table request. If you creating multiple tables then you either split the Tables statements or use ODS OUTPUT to capture results. You can use ODS OUTPUT CROSSTABFREQS=datasetname; as a statement in the Proc freq code to capture two-way tables.

 

This would have all the counts and percents, more less, and if you only want a specific value then you use the typical options to subset a data set.

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 2 replies
  • 703 views
  • 2 likes
  • 3 in conversation