Hello
This code calculate frequency of two way table .
In each cell we get number of rows.
I want to ask what is the way to create same structure of table with percent from total in each row.
For example:In first row there will be:
3/158=1/9% ,25/158=15.82% ,94/158=59.49%,17/158=10.76%,8/158=5.06%,11/158=6.96% ,158/158=100%
I want to see the results in Percent format with % symbol
What is the way to do it please?
proc tabulate data=sashelp.cars missing;
Title 'Two Way freq table';
class Origin Type;
var MSRP;
table Origin='' ALL,Type='Type Of car'*N=''*MSRP=''*F=Comma21. ALL/box='Origin of Car' misstext='0' ;
run;
I don't have a clue what you are doing with MSRP.
If you really want to see a % sign you have two choices. One is to make and use a VAR variable that is numeric with the MEAN statistic that will make the correct values and a percent format. Typically that new variable would be 1/0 coded variable with 1 meaning the characteristic of interest.
Or if you want to use ROWPCTN you need to make format that will look like a percent such as:
proc format; picture fakepercent low-high = '009.99%' ; run; proc tabulate data=sashelp.cars missing; Title 'Two Way freq table'; class Origin Type; var MSRP; table Origin='' ALL, Type='Type Of car'*rowpctN=''*f=fakepercent. ALL /box='Origin of Car' misstext='0' ; run;
If the only missing text will be with the percent then you would set misstext='0%' or similar. However if you may have more than one value missing your percents are going to look like your misstext setting. In which case perhaps a blank will be less jarring in appearance than a column/row with mixed percent signs and not.
Personally, I find % in a table to be messy.
How about simplifying life:
proc freq data=sashelp.cars;
table Origin * Type / nocol nopercent nofreq;
label Origin = 'Origin of Car' type='Type of Car';
run;
@Astounding wrote:
How about simplifying life:
proc freq data=sashelp.cars; table Origin * Type / nocol nopercent nofreq; label Origin = 'Origin of Car' type='Type of Car'; run;
OP explicitly states he wants the percent sign:
3/158=1/9% ,25/158=15.82% ,94/158=59.49%,17/158=10.76%,8/158=5.06%,11/158=6.96% ,158/158=100%
I want to see the results in Percent format with % symbol
Proc freq won't show the %.
In recent releases of PROC FREQ, you can use the FORMATP= option in the TABLES statement to format the percentages in crosstabulation tables.
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.
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.