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).


sas-innovate-2024.png

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.

 

Register now!

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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