Sentry Page Protection
Data Analysis [4-15]
Output Statement
(Proc Univariate)
So far, we have only seen examples where the analysis results are displayed on the Results window.
You might want to save the results to a data set instead sometimes.
This can be done by using the OUTPUT statement.
Example
Creating Output Data Set
Example
Proc Univariate data=school;
Var results;
Class group;
Output out=rslt Mean=Var1 STD=Var2;
Run;
The OUTPUT statement creates the RSLT data set:
Two statistics keywords were also specified in the OUTPUT statement:
- Mean = Var1
- STD = Var2
This generates the two variables (i.e. Var1 and Var2) in the output data set:
The Var1 and Var2 variables contain the Mean and Standard Deviation statistics, respectively.
Additional Statistics Keywords
In addition to mean and standard deviation, you can also request for the other statistics to be generated in the output data set.
Below are some of the more commonly used keywords:
- MAX
- MEAN
- MIN
- MODE
- N
- NMISS
- NOBS
- RANGE
- STD
- SUM
- Q1
- MEDIAN
- Q3
Example
Proc Univariate data=school;
Var results;
Class group;
Output out=rslt
Q1=Q1 Median=Median Q3=Q3;
Run;
For the complete list of statistics keywords, please visit here.
NOPRINT option
When using the OUTPUT statement, the analysis results are showing on both the Results window and the output data set.
The results on the Results window can be suppressed by using the NOPRINT option.
Example
Proc Univariate data=school noprint;
Var results;
Class group;
Output out=rslt
Q1=Q1 Median=Median Q3=Q3;
Run;
No results will be printed to the Results window:
Exercise
Locate the FISH data set from the SASHelp library.
Create a data set that contains the heaviest fish from each species.
Locate the FISH data set from the SASHelp library.
Create a data set that contains the heaviest fish from each species.
Need some help?
HINT:
The statistics keyword is MAX.
SOLUTION:
Proc Univariate data=sashelp.fish noprint;
Var weight;
Class species;
Output out=fish2 Max=MaxWeight;
Run;
Fill out my online form.