Creating a Summarized Data Set Using PROC MEANS

OUTPUT Statement Syntax

To write summary statistics to a new data set, use the OUTPUT statement in the MEANS procedure.
Syntax, OUTPUT statement:
OUTPUT OUT=SAS-data-set statistic=variable(s);
  • OUT= specifies the name of the output data set.
  • statistic= specifies which statistic to store in the output data set.
  • variable(s) specifies the names of the variables to create. These variables represent the statistics for the analysis variables that are listed in the VAR statement.
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 specific statistics to produce, use the statistic=variable(s) option in the OUTPUT statement.

Specifying Statistics Using PROC MEANS

To specify specific statistics in the output data set, you must specify the statistic and then list all of the variables names that contain the value for one or more statistics that are specified in the VAR statement. 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;
Figure 9.9 Report Created by PROC MEANS
Report Created by PROC MEANS
To see the contents of the output data set, submit a PROC PRINT step.
proc print data=work.sum_gender; 
run;
Figure 9.10 Data Set Created by PROC PRINT
Data Set Created by PROC PRINT
Tip
You can use the NOPRINT option in the PROC MEANS statement to suppress the default report. 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;
Tip
In addition to the variables that you specify, PROC MEANS adds the _TYPE_ and _FREQ_ variables to the output data set. When no statistic keywords are specified, PROC MEANS also adds the variable _STAT_.
Last updated: January 10, 2018
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.144.244.250