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

SAS Innovate 2025: Call for Content

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!

Submit your idea!

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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