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
Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!
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.
Ready to level-up your skills? Choose your own adventure.