## Calculating percents

Occasional Contributor
Posts: 18

# Calculating percents

Is there procedure that calculates percentages and creates an output data set, like "proc tabulate" does for reports.

Thanks;
Masoud
Super Contributor
Posts: 3,176

## Re: Calculating percents

Look at PROC MEANS, and possibly using a BY statement with your variable list.

Scott Barry
SBBWorks, Inc.

proc calculate percentage site:sas.com Message was edited by: sbb
SAS Super FREQ
Posts: 9,371

## Re: Calculating percents

Hi:
Although PROC FREQ will create an output dataset with percentages, is there a reason you don't want to use PROC TABULATE to calculate percentages??? For example, the program below:
[pre]
proc freq data=sashelp.class;
tables age/out=work.frqage;
run;

ods listing;
proc print data=work.frqage;
title 'Data set created by PROC FREQ';
run;

proc tabulate data=sashelp.class
out=work.tabage(rename=(N=Count PCTN_0=Percent));
class age;
table age,
n pctn;
run;

proc print data=work.tabage;
title 'Data set created by PROC TABULATE';
title2 'You can drop or ignore _TYPE_, _TABLE_ and _PAGE_';
run;

title;
[/pre]

generates the same results as shown at the bottom of this post.

cynthia
[pre]
PROC FREQ output dataset:
Data set created by PROC FREQ

Obs Age COUNT PERCENT
1 11 2 10.5263
2 12 5 26.3158
3 13 3 15.7895
4 14 4 21.0526
5 15 4 21.0526
6 16 1 5.2632

------------------------------------------------------------

PROC TABULATE output dataset:
Data set created by PROC TABULATE
You can drop or ignore _TYPE_, _TABLE_ and _PAGE_

Obs Age _TYPE_ _PAGE_ _TABLE_ Count Percent
1 11 1 1 1 2 10.5263
2 12 1 1 1 5 26.3158
3 13 1 1 1 3 15.7895
4 14 1 1 1 4 21.0526
5 15 1 1 1 4 21.0526
6 16 1 1 1 1 5.2632

[/pre]
Occasional Contributor
Posts: 18