TRANSPOSE Procedure

Example 2: Naming Transposed Variables

Features:
PROC TRANSPOSE statement options:
NAME=
PREFIX=

ID statement

Data set: SCORE
This example uses the values of a variable and a user-supplied value to name transposed variables.

Program

options nodate pageno=1 linesize=80 pagesize=40;
proc transpose data=score out=idnumber name=Test
     prefix=sn;
    id studentid;
run;
proc print data=idnumber noobs;
   title 'Student Test Scores';
run;

Program Description

Set the SAS system options. The NODATE option suppresses the display of the date and time in the output. PAGENO= specifies the starting page number. LINESIZE= specifies the output line length, and PAGESIZE= specifies the number of lines on an output page.
options nodate pageno=1 linesize=80 pagesize=40;
Transpose the data set. PROC TRANSPOSE transposes only the numeric variables, Test1, Test2, and Final, because no VAR statement appears. OUT= puts the result of the transposition in the IDNUMBER data set. NAME= specifies Test as the name for the variable that contains the names of the variables in the input data set that the procedure transposes. The procedure names the transposed variables by using the value from PREFIX=, sn, and the value of the ID variable StudentID.
proc transpose data=score out=idnumber name=Test
     prefix=sn;
    id studentid;
run;
Print the IDNUMBER data set. The NOOBS option suppresses the printing of observation numbers.
proc print data=idnumber noobs;
   title 'Student Test Scores';
run;

Output

The following data set is the output data set, IDNUMBER.
Student Test Scores
     
                        Student Test Scores                              1

  Test     sn0545    sn1252    sn1167    sn1230    sn2527    sn4860    sn0674

  Test1      94        51        95        63        80        92        75
  Test2      91        65        97        75        76        40        78
  Final      87        91        97        80        71        86        72