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

Hi, 

 

I am writing several proc freq procedures and am wanting to store them output table in a file. I am specifying that I only want the frequency and the column percentage. However, when I open the table that is created (newdata) the percentage stored is the total frequency percentage not the column percentage. What am I doing wrong? The results tab shows what I am wanting in the frequency table. 

 

Here is my code.......

 

proc freq data=mydata;

tables varA*varB/ out=newdata nopercent nocum norow;

run;

 

But the table "newdata" is showing 

 

varA    varB    Frequency Count       Percent of Total Frequency 

 

Not

 

varA    varB    Frequency Count       Column Percentage

 

1 ACCEPTED SOLUTION

Accepted Solutions
Reeza
Super User

Change the drop statement to reflect the variables you want to drop, they are space separated, not comma delimited.

 

(drop=pct_row percent)

View solution in original post

6 REPLIES 6
Reeza
Super User

You need to add OUTPCT to add the pct columns to the output data set, check the docs for details.

This is a bit of a roundabout way to get what you want, but easy enough. Someone else may have a better answer 🙂

 

proc freq data=sashelp.class;
table age*sex/out=want(drop=pct_row) outpct norow nocum;
run;

proc print data=want;
run;

 

 

 

BStats
Calcite | Level 5

This drops the row percentage. Thank you. How do I also get it to drop the percentage of frequency total? I tried adding pct_tabl but it did not work 

 

(drop=pct_row, pct_tabl)

Astounding
PROC Star

The variable name holding the total percent is PERCENT:

 

(drop=percent)

Reeza
Super User

Change the drop statement to reflect the variables you want to drop, they are space separated, not comma delimited.

 

(drop=pct_row percent)
BStats
Calcite | Level 5

Thank you

ballardw
Super User

If you want to use Proc Freq to generate multiple output sets from a single input dataset use multiple TABLE statements. Each table statement will only build one output data set.

sas-innovate-2024.png

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!

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.

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
  • 6 replies
  • 1280 views
  • 0 likes
  • 4 in conversation