I am new to SAS programming and I trying to work on proc means statement. For controlling my decimal value in the output I have used maxdec option however when I tried to assign a new dataset to the output and print it my decimal values are not controlled in the standard deviation. can someone help me figure out how to control the decimal points in the output dataset?? here is the code I used:
proc means data=sashelp.class maxdec=2 noprint;
var height weight;
output out=dsn2 Mean= Median= Min= Max= STD=/autoname;
run;
proc print data=dsn2;
run;
The MAXDEC option just controls how the PRINTOUT is generated.
If you want to control the number of decimal places used when printing a dataset you need to attach a format to the variable(s). To control the formats attached to variables in PROC MEANS use a FORMAT statement. If you attach a format to the analysis variable then the same format will be attached to any statistic derived from that variable.
So you could use a FORMAT statement in the PROC MEANS step, or when creating the input dataset. Or you could attach the format to the variable in the output dataset later, or just during the PROC PRINT.
Result
Note that PROC MEANS will even let you attach a format to the generated statistic variables directly, but you will get a WARNING about variable not found in the input dataset.