Chapter Contents

Previous

Next
The TRANSPOSE Procedure

Overview

The TRANSPOSE procedure creates an output data set by restructuring the values in a SAS data set, transposing selected variables into observations. The TRANSPOSE procedure can often eliminate the need to write a lengthy DATA step to achieve the same result. Further, the output data set can be used in subsequent DATA or PROC steps for analysis, reporting, or further data manipulation.

PROC TRANSPOSE does not produce printed output. To print the output data set from the PROC TRANSPOSE step, use PROC PRINT, PROC REPORT, or another SAS reporting tool.

A transposed variable is a variable the procedure creates by transposing the values of an observation in the input data set into values of a variable in the output data set.

A Simple Transposition illustrates a simple transposition. In the input data set, each variable represents the scores from one tester. In the output data set, each observation now represents the scores from one tester. Each value of _NAME_ is the name of a variable in the input data set that the procedure transposed. Thus, the value of _NAME_ identifies the source of each observation in the output data set. For example, the values in the first observation in the output data set come from the values of the variable Tester1 in the input data set. The statements that produce the output follow.

proc print data=proclib.product noobs;
   title 'The Input Data Set';
run;

proc transpose data=proclib.product
               out=proclib.product_transposed;
run;

proc print data=proclib.product_transposed noobs;
   title 'The Output Data Set';
run;

A Simple Transposition
[HTML Output]  [Listing Output]

A Transposition with BY Groups is a more complex example that uses BY groups. The input data set represents measurements of fish weight and length at two lakes. The statements that create the output data set

A Transposition with BY Groups
[HTML Output]  [Listing Output]

For a complete explanation of the SAS program that produces A Transposition with BY Groups , see Transposing BY Groups .


Chapter Contents

Previous

Next

Top of Page

Copyright 1999 by SAS Institute Inc., Cary, NC, USA. All rights reserved.