## proc tabulate percentages by group and column

Occasional Contributor
Posts: 8

# proc tabulate percentages by group and column

Hello,

I am trying to calculate the percentage in proc tabulate for a group of colleges.  I've created a sum, then a percentage of a column's total, but my output gives the total percentage based on the entire group of colleges and not an individual college.

``````title;
proc tabulate data=complement_master format=comma9.;
format FT \$fte. level \$lvl.;
var sch;
class COLLEGE level ft;
table  (COLLEGE ALL)*(FT ALL='College Total'), SCH*LEVEL*(SUM COLPCTSUM="%"*f=BEST4.)
SCH ALL='Total'
/misstext='0' printmiss;
WHERE SUBJECTCOLL IN ('AR', 'BU');
title 'Table 4 - SCH by College, Type of Faculty and Level of Instruction, % WRONG';
quit;``````

The percentages should only be calculated for the college of "AR" and the College of "BU".  Basically, sums and percentages for each college and a total summary for the entire school.

Am I making sense?

Also, I am using Base SAS 9.

Super User
Posts: 13,523

## Re: proc tabulate percentages by group and column

You can specify a denominator class variable using pctn<classvar> or pctsum<classvar>. Do not use the <classvar> with rowpct or colpct statistics.

So you may be wanting Pctsum<college> instead of colpctsum.

But without any data its hard to be sure.

Occasional Contributor
Posts: 8

## Re: proc tabulate percentages by group and column

Thank you.  I appreciate your time.

If I understand you correctly, I modified it a bit to show this:

``````title;
proc tabulate data=complement_master format=comma9.;
format FT \$fte. level \$lvl.;
var sch;
class COLLEGE level ft;
table  (COLLEGE ALL)*(FT ALL='College Total'), (LEVEL ALL)*SCH*(SUM PCTSUM<COLLEGE ALL>="%"*f=BEST4.)
SCH ALL='Total'
/misstext='0' printmiss;
WHERE SUBJECTCOLL IN ('AR', 'BU');
title 'Table 4 - SCH by College, Type of Faculty and Level of Instruction, % WRONG';
quit;``````

I'm attaching the output table.  The school Architecture is showing 18.3%.  It is the percentage of FT (Full Time) to the Total college (1,163/6,357).  It should be 1,163/1,527 or 76.2% .  I've tried substituting or leaving out ALL in the <COLLEGE> classvar, but the error message is PctSum based is not in table.  A PctSum crossing has no denominator.

Occasional Contributor
Posts: 12

## Re: proc tabulate percentages by group and column

[ Edited ]

Occasional Contributor
Posts: 8

## Re: proc tabulate percentages by group and column

I apologize for the late reply. I have been out of the country. That problem wasn't resolved. It was a while ago, but I think I had to create a work around (i.e, created a different report).

Discussion stats
• 4 replies
• 233 views
• 0 likes
• 3 in conversation