Hello, I want to get MEAN and SD from PROC SURVEYMEANS (my original data is a survey with weights). In PROC MEANS, STD calculates standard deviation; but in PROC SURVEYMEANS, STD calculates the standard deviation of SUM. Also, in the following example, MEAN does not calculate the mean.
How do I calculate the MEAN and STD for a variable in PROC SURVEYMEANS?
Thanks
PROC MEANS DATA=SASHELP.CLASS NONOBS MAXDEC=2 SUM MEAN STD ;
VAR AGE HEIGHT;
RUN;
PROC SURVEYMEANS DATA=SASHELP.CLASS n mean STD df CLM ;
VAR AGE HEIGHT;
RUN;
PROC SURVEYMEANS DATA=SASHELP.CLASS nobs mean SUM df CLM ;
VAR AGE HEIGHT;
RUN;
I have changed n to nobs and STD to SUM. The code has worked for me.
“If you specify the statistic-keywords of your interest including SUM (i.e., estimated population total when the appropriate sampling weights are used) in that statement, the procedure computes STD by default.” (SAS Documentation).
Thank you, pkm_edu. Yes, you are right. NOBS is the appropriate keyword to ask for the number of observations. That solves the error for mean.
It sounds I need to use this approach to estimate SD approach https://support.sas.com/kb/45/701.html#:~:text=Use%20PROC%20SURVEYMEANS%20to%20estimate%20the%20weig....
Thanks
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!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.