Building models with SAS Enterprise Miner, SAS Factory Miner, SAS Visual Data Mining and Machine Learning or just with programming

Determining mean and average from dataset

Occasional Contributor
Posts: 7

Determining mean and average from dataset

Hi guys. How can I determine the mean and average for fields of the Total Cholesterol and Glucose of an individual based on age and gender of an individual from the diabetes dataset? Should I sort it first? Any help and advice will be appreciated. Thanks

Diabetes File:



Trusted Advisor
Posts: 1,131

Re: Determining mean and average from dataset

[ Edited ]

wouldn't you want to categorize the age first, since it is a numeric variable 

convert it into a character variable. You could get the means from proc means as below. This is an untested code so please change the variable names as per your dataset. The autoname will create the mean variable names by concatenating the  variable name with statistics name example chol_mean glucose_mean



proc means data=have nway;
class age gender;
var chol glucose;
output out=means mean=/autoname;


Trusted Advisor
Posts: 1,630

Re: Determining mean and average from dataset

[ Edited ]

You could apply a format to the AGE variable to group it, as explained by @Jim_G in this thread:


Then you can use PROC MEANS or PROC SUMMARY on the data. If you use PROC SUMMARY with a CLASS statement, no sorting is necessary.


By the way, the "mean" is the same thing as the "average". Smiley Wink

Super User
Posts: 17,905

Re: Determining mean and average from dataset

If you're using EG and the tasks you can use the Summary Task. 


Add age and gender into the GROUP variables and Cholesterol into the analysis variables. 


If you're looking for code here's some examples:

Ask a Question
Discussion stats
  • 3 replies
  • 1 like
  • 4 in conversation