SAS Programming

DATA Step, Macro, Functions and more
BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
Emma_at_SAS
Lapis Lazuli | Level 10

I want to limit the decimal places to 2 for the output for STD ERROR of SUM from PROC SURVEYMEANS.

In the following example the Std Error of Sum = 267.928448 but I want it to be 267.93. Thanks

 

data TEST;
do ID = 1 to 30;
HEIGHT = round(130 + rand('Uniform') * 50, 0.01); /* Heights with 2 decimal places */
WEIGHT = rand('Uniform'); /* Generating random survey weights */
output;
end;
run;

/* Run PROC SURVEYMEANS with weights */
proc surveymeans data=TEST min max sum std mean stderr plots=none;
var HEIGHT;
weight WEIGHT;
run;

 

1 ACCEPTED SOLUTION

Accepted Solutions
PaigeMiller
Diamond | Level 26

Write the results to a SAS data set, then apply format 12.2 (or any other format you would like) to the output data set.

 

ods select none;
ods output statistics=statistics;
/* Run PROC SURVEYMEANS with weights */
proc surveymeans data=TEST min max sum std mean stderr;
var HEIGHT;
weight WEIGHT;
run;
ods select all;
--
Paige Miller

View solution in original post

3 REPLIES 3
PaigeMiller
Diamond | Level 26

Write the results to a SAS data set, then apply format 12.2 (or any other format you would like) to the output data set.

 

ods select none;
ods output statistics=statistics;
/* Run PROC SURVEYMEANS with weights */
proc surveymeans data=TEST min max sum std mean stderr;
var HEIGHT;
weight WEIGHT;
run;
ods select all;
--
Paige Miller
Emma_at_SAS
Lapis Lazuli | Level 10

Thanks @PaigeMiller

It is interesting that the output from ODS output renames Std Error of MEan to StdErr and renames Std Error of Sum to StdDev and I need to format StdDev. But that solves my problem. Thanks

 

Emma_at_SAS_0-1709226062316.png

 

PaigeMiller
Diamond | Level 26

@Emma_at_SAS 

 

When you do a PROC PRINT here, use the LABEL option

 

proc print data=statistics label;
    format stddev stderr 12.2;
run;
--
Paige Miller

sas-innovate-white.png

Our biggest data and AI event of the year.

Don’t miss the livestream kicking off May 7. It’s free. It’s easy. And it’s the best seat in the house.

Join us virtually with our complimentary SAS Innovate Digital Pass. Watch live or on-demand in multiple languages, with translations available to help you get the most out of every session.

 

Register now!

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
  • 3 replies
  • 1067 views
  • 2 likes
  • 2 in conversation