BookmarkSubscribeRSS Feed
jsasusr
Fluorite | Level 6

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.

4 REPLIES 4
ballardw
Super User

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.

jsasusr
Fluorite | Level 6

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.

Bedi
Calcite | Level 5

Hello, I am facing the same issue ...was this resolved ?

jsasusr
Fluorite | Level 6
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).


hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

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