Proc Tabulate PCTN Denominator Troubles

Reply
Occasional Contributor
Posts: 16

Proc Tabulate PCTN Denominator Troubles

Hey folks, first time posting here. I'm running into trouble when trying to get a Percent N (PCTN) from a proc tabulate. We're trying to see how male/female college course enrollments and withdrawals differ, across several years. The following image shows 3 CSCI course, with female and male enrollment counts in the first column:

 

pctn.png

 

I want PCTN to reflect the INTRA-course, INTRA-year enrollment totals (i.e. the denominator should be the enrollment total for that course, in that year). So, for year 2013 and CSCI course 181, the F enrollment count of 68 should give a PCTN of 51.1%. Can someone help me modify my code to produce this result? Here's my code ('ay' is academic year, btw):

 

proc tabulate data= csci_grades missing;
     where ay in ('2013','2014') and sex in ('M','F');
     class course sex ay;
     var enroll withdraw_flag;
     table course=' '*(sex=' ' all='Course Total'), ay*(enroll*n enroll*pctn withdraw_flag*n withdraw_flag*pctn all='Inner All') all='Outer All';
run;

 

Thanks so much for your help!! Smiley Happy

Super User
Posts: 11,134

Re: Proc Tabulate PCTN Denominator Troubles

If you provide some example data in the form of data step code we can test things a tad better.

 

It looks like you want a form of COLPCTN<enroll>

SAS Super FREQ
Posts: 8,820

Re: Proc Tabulate PCTN Denominator Troubles

Hi:

  Here is a sample program that illustrates the use of PCTN, ROWPCTN and COLPCTN and then shows calculating a percent of a group based on using a custom denominator. The program makes some fake data that sort of mimics what you are doing with nested groups in the row dimension and a date-based variable in the column dimension. You can see the same values for the rows and columns in every table, but the percent numbers change on the denominator being used.

 

cynthia

 

Here's an example of TABLE 1 (percent of Grand Total) versus TABLE 4 (custom denominator) since the program is so long, I am not going to post all 4 tables, but you should be able to run the program yourself to see the other tables.

 

TABLE 1

table1.png

TABLE 4

table4.png


proc tabulate data=newprice;
  class regionname productname date;
     var sale ;
     table regionname=' '*(productname=' ' all='Course Total') all,
           date*(sale*(n pctn)) all='Outer All'*(n pctn) /
           box='1 divided by grand total';
     table regionname=' '*(productname=' ' all='Course Total') all,
           date*(sale*(n rowpctn)) all='Outer All'*(n rowpctn) /
           box='2 divided by row total'; 
     table regionname=' '*(productname=' ' all='Course Total') all,
           date*(sale*(n colpctn)) all='Outer All'*(n colpctn) /
           box='3 divided by column total';
     table regionname=' '*(productname=' ' all='Course Total'),
           date*(sale*(n pctn<productname all>)) all='Outer All'*(n pctn<productname all>) /
           box='4 using custom denom to get productname total';
     format date monname3.;
run;

Ask a Question
Discussion stats
  • 2 replies
  • 260 views
  • 0 likes
  • 3 in conversation