Your SAS programs, embedded in web apps and elsewhere

Proc means to find the average based on a character column

Accepted Solution Solved
Reply
Super Contributor
Posts: 483
Accepted Solution

Proc means to find the average based on a character column

Is there a way to use proc means to find the average based on a character column?  Lets say I have a column that has two values male and female.  I want to know the percent of men and the percent of women.  Then do the same over a period of years.


Accepted Solutions
Solution
‎08-07-2015 04:08 PM
Super User
Posts: 17,890

Re: Proc means to find the average based on a character column

Use Proc Freq instead.

View solution in original post


All Replies
Solution
‎08-07-2015 04:08 PM
Super User
Posts: 17,890

Re: Proc means to find the average based on a character column

Use Proc Freq instead.

Super Contributor
Posts: 483

Re: Proc means to find the average based on a character column

Thanks that is exactly what I want.

Super Contributor
Posts: 483

Re: Proc means to find the average based on a character column

Is there a way to use proc freq to compute percentages on two columns?  I’m trying to calculate the percent of whole based on gender and the percent of whole based on year.  Note the second percent of whole would not be a sub percent of the first category.  I could run two separate freq statements and merge then together, but I’m worried about processing speed.  My desired output would look like.

ACADEMIC_PERIOD_DESC

GENDERCOUNTPERCENTWholePercent of whole
Fall 2010Female20990.587462.931080.200424
Fall 2011Female21670.575412.931080.196313
Fall 2012Female20750.582542.931080.198746
Fall 2013Female20910.589842.931080.201236
Fall 2014Female21170.595832.931080.20328
Fall 2010Male14550.407222.061340.197551
Fall 2011Male15980.424322.061340.205847
Fall 2012Male14860.417182.061340.202383
Fall 2013Male14490.408742.061340.198288
Fall 2014Male14350.403882.061340.195931
Fall 2010Not Reported190.005320.007560.703704
Fall 2011Not Reported10.000270.007560.035714
Fall 2012Not Reported10.000280.007560.037037
Fall 2013Not Reported50.001410.007560.186508
Fall 2014Not Reported10.000280.007560.037037
Super Contributor
Posts: 483

Re: Proc means to find the average based on a character column

I was hoping this table in

Request

Equivalent to

tables A*(B C);

tables A*B    A*C;

tables (A B)*(C D);

tables A*C    B*C    A*D    B*D;

tables (A B C)*D;

tables A*D    B*D    C*D;

tables A – – C;

tables A    B    C;

tables (A – – C)*D;

tables A*D    B*D    C*D;

Base SAS(R) 9.2 Procedures Guide: Statistical Procedures, Third Edition

would help but I can't seem to figure out how to use the table statement to produce the desired result.

☑ This topic is SOLVED.

Need further help from the community? Please ask a new question.

Discussion stats
  • 4 replies
  • 990 views
  • 0 likes
  • 2 in conversation