You might want to create an output SAS data set that contains just the summarized variable. You can do this by using the OUTPUT statement in PROC MEANS. |
General form, OUTPUT statement:
where
|
When you use the OUTPUT statement, the summary statistics N, MEAN, STD, MIN, and MAX are produced for all of the numeric variables or for all of the variables that are listed in a VAR statement by default. To specify which statistics to produce, use the STATISTIC= option. |
Specifying the STATISTIC= option
You can specify which statistics to produce in the output data set. To do so, you must specify the statistic and then list all of the variables. The variables must be listed in the same order as in the VAR statement. You can specify more than one statistic in the OUTPUT statement. The following program creates a typical PROC MEANS report and also creates a summarized output data set. proc means data=clinic.diabetes; var age height weight; class sex; output out=work.sum_gender mean=AvgAge AvgHeight AvgWeight min=MinAge MinHeight MinWeight; run; |
Sex | N Obs | Variable | N | Mean | Std Dev | Minimum | Maximum |
F | 11 | Age Height Weight |
11 11 11 |
48.9090909 63.9090909 150.4545455 |
13.3075508 2.1191765 18.4464828 |
16.0000000 61.0000000 102.0000000 |
63.0000000 68.0000000 168.0000000 |
M | 9 | Age Height Weight |
9 9 9 |
44.0000000 70.6666667 204.2222222 |
12.3895117 2.6457513 30.2893454 |
15.0000000 66.0000000 140.0000000 |
54.0000000 75.0000000 240.0000000 |
To see the contents of the output data set, submit the following PROC PRINT step. proc print data=work.sum_gender; run; |
Obs | Sex | _TYPE_ | _FREQ_ | AvgAge | AvgHeight | AvgWeight | MinAge | MinHeight | MinWeight |
1 | 0 | 20 | 46.7000 | 66.9500 | 174.650 | 15 | 61 | 102 | |
2 | F | 1 | 11 | 48.9091 | 63.9091 | 150.455 | 16 | 61 | 102 |
3 | M | 1 | 9 | 44.0000 | 70.6667 | 204.222 | 15 | 66 | 140 |
You can use the NOPRINT option in the PROC MEANS statement to prevent the default report from being created. For example, the following program creates only the output data set: proc means data=clinic.diabetes noprint; var age height weight; class sex; output out=work.sum_gender mean=AvgAge AvgHeight AvgWeight; run; |
In addition to the variables that you specify, the procedure adds the _TYPE_ and _FREQ_ variables to the output data set. When no statistic keywords are specified, PROC MEANS also adds the variable _STAT_. For more information about these variables, see the SAS documentation for the MEANS procedure. |