Previous Page | Next Page

The TRANSPOSE Procedure

Example 6: Transposing Data for Statistical Analysis


Procedure features:

COPY statement

VAR statement


This example arranges data to make it suitable for either a multivariate or a univariate repeated-measures analysis.

The data is from Chapter 8, "Repeated-Measures Analysis of Variance," in SAS System for Linear Models, Third Edition.


Program 1

 Note about code
options nodate pageno=1 linesize=80 pagesize=40;
 Note about code
data weights;
   input Program $ s1-s7;
   datalines;
CONT  85 85 86 85 87 86 87
CONT  80 79 79 78 78 79 78
CONT  78 77 77 77 76 76 77
CONT  84 84 85 84 83 84 85
CONT  80 81 80 80 79 79 80
RI    79 79 79 80 80 78 80
RI    83 83 85 85 86 87 87
RI    81 83 82 82 83 83 82
RI    81 81 81 82 82 83 81
RI    80 81 82 82 82 84 86
WI    84 85 84 83 83 83 84
WI    74 75 75 76 75 76 76
WI    83 84 82 81 83 83 82
WI    86 87 87 87 87 87 86
WI    82 83 84 85 84 85 86
;
 Note about code
data split;
   set weights;
   array s{7} s1-s7;
   Subject + 1;
   do Time=1 to 7;
      Strength=s{time};
      output;
   end;
   drop s1-s7;
run;
 Note about code
proc print data=split(obs=15) noobs;
   title 'SPLIT Data Set';
   title2 'First 15 Observations Only';
run;

Output 1

                                 SPLIT Data Set                                1
                           First 15 Observations Only

                     Program    Subject    Time    Strength

                      CONT         1         1        85   
                      CONT         1         2        85   
                      CONT         1         3        86   
                      CONT         1         4        85   
                      CONT         1         5        87   
                      CONT         1         6        86   
                      CONT         1         7        87   
                      CONT         2         1        80   
                      CONT         2         2        79   
                      CONT         2         3        79   
                      CONT         2         4        78   
                      CONT         2         5        78   
                      CONT         2         6        79   
                      CONT         2         7        78   
                      CONT         3         1        78   

Program 2

 Note about code
options nodate pageno=1 linesize=80 pagesize=40;
 Note about code
proc transpose data=split out=totsplit prefix=Str;
 Note about code
   by program subject;
   copy time strength;
 Note about code
   var strength;
run;
 Note about code
proc print data=totsplit(obs=15) noobs;
   title  'TOTSPLIT Data Set';
   title2 'First 15 Observations Only';
run;

Output 2

 Note about figure
                               TOTSPLIT Data Set                               1
                           First 15 Observations Only

   Program Subject Time Strength  _NAME_  Str1 Str2 Str3 Str4 Str5 Str6 Str7

    CONT      1      1     85    Strength  85   85   86   85   87   86   87 
    CONT      1      2     85               .    .    .    .    .    .    . 
    CONT      1      3     86               .    .    .    .    .    .    . 
    CONT      1      4     85               .    .    .    .    .    .    . 
    CONT      1      5     87               .    .    .    .    .    .    . 
    CONT      1      6     86               .    .    .    .    .    .    . 
    CONT      1      7     87               .    .    .    .    .    .    . 
    CONT      2      1     80    Strength  80   79   79   78   78   79   78 
    CONT      2      2     79               .    .    .    .    .    .    . 
    CONT      2      3     79               .    .    .    .    .    .    . 
    CONT      2      4     78               .    .    .    .    .    .    . 
    CONT      2      5     78               .    .    .    .    .    .    . 
    CONT      2      6     79               .    .    .    .    .    .    . 
    CONT      2      7     78               .    .    .    .    .    .    . 
    CONT      3      1     78    Strength  78   77   77   77   76   76   77 

Previous Page | Next Page | Top of Page