Hi Guys i would like to know how to come out with overall means on the attached table using SAS?
If you just want the means of veld cross-tabulated per agegroup and month, do this:
proc tabulate data=luks;
format age agegroup. month mymth.;
class age month;
var veld;
table age, month*veld*mean;
run;
after creating the formats like this:
proc format;
value agegroup
1 = "0-4"
2 = "5-8"
3 = "9-12"
4 = ">13"
;
value mymth
1 ="January"
2 = "February"
3 = "March"
4 = "April"
5 = "May"
;
run;
If you had SAS dates instead of just the month numbers, you could use SAS' predefined formats.
Welcome to the communities!
Please supply example data in a data step with datalines, so we have something to play with.
If you just want the means of veld cross-tabulated per agegroup and month, do this:
proc tabulate data=luks;
format age agegroup. month mymth.;
class age month;
var veld;
table age, month*veld*mean;
run;
after creating the formats like this:
proc format;
value agegroup
1 = "0-4"
2 = "5-8"
3 = "9-12"
4 = ">13"
;
value mymth
1 ="January"
2 = "February"
3 = "March"
4 = "April"
5 = "May"
;
run;
If you had SAS dates instead of just the month numbers, you could use SAS' predefined formats.
Another method is to use PROC MEANS:
proc means data=luks noprint;
class Veld Sex Month Age;
var BCS;
output out=rawmeans mean=mean std=sd n=n;
run;
In the dataset rawmeans, the following _type_ variables identify the raw means that correspond to the lsmeans in your PROC MIXED (plus as a bonus, the overall mean for BCS).
_type_=0 Overall mean
_type_=1 Mean of each level of age
_type_=2 Mean of each level of month
_type_=4 Mean of each level of sex
_type_=8 Mean of each level of veld
_type_=10 Mean of each level of veld*month
So now these are available for output or for merging against the lsmeans dataset (which you could get with an ODS statement with PROC MIXED).
SteveDenham
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
ANOVA, or Analysis Of Variance, is used to compare the averages or means of two or more populations to better understand how they differ. Watch this tutorial for more.
Find more tutorials on the SAS Users YouTube channel.