BookmarkSubscribeRSS Feed
Emma_at_SAS
Lapis Lazuli | Level 10

 

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;
2 REPLIES 2
pkm_edu
Quartz | Level 8

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).

Emma_at_SAS
Lapis Lazuli | Level 10

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

hackathon24-white-horiz.png

The 2025 SAS Hackathon Kicks Off on June 11!

Watch the live Hackathon Kickoff to get all the essential information about the SAS Hackathon—including how to join, how to participate, and expert tips for success.

YouTube LinkedIn

How to Concatenate Values

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 2 replies
  • 1303 views
  • 0 likes
  • 2 in conversation