BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
westbestern
Obsidian | Level 7

I have several categorical variables like gender, race, etc. where I want to find the mean of each category. For example my variable is race and race=1 means white, race=2 means Black, race=3 means Asian/PI. I want to find the mean number of people in my dataset who are members of each race, as well as the standard deviation. Would I use PROC FREQ for this or PROC MEANS?

1 ACCEPTED SOLUTION

Accepted Solutions
PaigeMiller
Diamond | Level 26

If I am understanding you properly, you run PROC FREQ first to count the number of people in each race, and create an output data set. Then you take this output data set into PROC MEANS and compute the mean and standard deviation.

 

--
Paige Miller

View solution in original post

3 REPLIES 3
PaigeMiller
Diamond | Level 26

If I am understanding you properly, you run PROC FREQ first to count the number of people in each race, and create an output data set. Then you take this output data set into PROC MEANS and compute the mean and standard deviation.

 

--
Paige Miller
samanehMA
Calcite | Level 5

Could you please write the code for that?
I understand what you mean. But I can't write the code as you are doing. 

Thank you.

 

Tom
Super User Tom
Super User

I do not understand what you want.

 

It sounds like you want to count and take the mean of the counts.

But you don't need to do that as the mean of the counts is just the total number of observations divided by the number of distinct values.

 

For example if you had GENDER coded as M and F there are two gender categories.  So the mean of the count of people per category is N/2.

 

What do intend to DO with this mean?  What value would a SD add?

 

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

Mastering the WHERE Clause in PROC SQL

SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.

Find more tutorials on the SAS Users YouTube channel.

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