I'm trying to output summary statistics from PROC FREQ so that I can use PROC SGPLOT to plot column percentage on an X-axis.
I'm trying to following the SAS documentation: "If you specify the OUTPCT option for a two-way or multiway table, the output data set also includes row, column, and table percentages."
PROC FREQ DATA=subset;
TABLES make*origin / OUT=OUTPCT;
RUN;
The above syntax only produces a data set w/ Count and Total Percent.
What is the proper format for the OUT= option?
How do I incorporate OUTEXPECT or OUTPCT or PCT_COL into the syntax?
Thanks!
You did not include the OUTPCT option on the TABLES statement. You used OUTPCT as the NAME of the dataset that the OUT= option is creating.
PROC FREQ DATA=sashelp.cars;
TABLES make*origin / OUT=want OUTPCT noprint;
RUN;
proc print data=want(obs=4);
run;
Obs Make Origin COUNT PERCENT PCT_ROW PCT_COL 1 Acura Asia 7 1.63551 100 4.4304 2 Audi Europe 19 4.43925 100 15.4472 3 BMW Europe 20 4.67290 100 16.2602 4 Buick USA 9 2.10280 100 6.1224
You did not include the OUTPCT option on the TABLES statement. You used OUTPCT as the NAME of the dataset that the OUT= option is creating.
PROC FREQ DATA=sashelp.cars;
TABLES make*origin / OUT=want OUTPCT noprint;
RUN;
proc print data=want(obs=4);
run;
Obs Make Origin COUNT PERCENT PCT_ROW PCT_COL 1 Acura Asia 7 1.63551 100 4.4304 2 Audi Europe 19 4.43925 100 15.4472 3 BMW Europe 20 4.67290 100 16.2602 4 Buick USA 9 2.10280 100 6.1224
PROC FREQ DATA=sashelp.class;
TABLES sex*age / OUTPCT out=OUTPCT;
RUN;
You mean like that?
OUT= names the data set created with the name following the =. OUTPCT as an option would look like:
PROC FREQ DATA=subset;
TABLES make*origin / OUT= mydatasetname OUTPCT;
RUN;
@_maldini_ wrote:
I'm trying to output summary statistics from PROC FREQ so that I can use PROC SGPLOT to plot column percentage on an X-axis.
I'm trying to following the SAS documentation: "If you specify the OUTPCT option for a two-way or multiway table, the output data set also includes row, column, and table percentages."
PROC FREQ DATA=subset; TABLES make*origin / OUT=OUTPCT; RUN;
The above syntax only produces a data set w/ Count and Total Percent.
What is the proper format for the OUT= option?
How do I incorporate OUTEXPECT or OUTPCT or PCT_COL into the syntax?
Thanks!
It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.
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.
Ready to level-up your skills? Choose your own adventure.