Previous Page | Next Page

The TRANSPOSE Procedure

Example 5: Naming Transposed Variables When the ID Variable Has Duplicate Values


Procedure features:

PROC TRANSPOSE statement option:

LET


This example shows how to use values of a variable (ID) to name transposed variables even when the ID variable has duplicate values.


Program

 Note about code
options nodate pageno=1 linesize=64 pagesize=40;
 Note about code
data stocks;
    input Company $14. Date $ Time $ Price;
    datalines;
Horizon Kites jun11 opening 29
Horizon Kites jun11 noon    27
Horizon Kites jun11 closing 27
Horizon Kites jun12 opening 27
Horizon Kites jun12 noon    28
Horizon Kites jun12 closing 30
SkyHi Kites   jun11 opening 43
SkyHi Kites   jun11 noon    43
SkyHi Kites   jun11 closing 44
SkyHi Kites   jun12 opening 44
SkyHi Kites   jun12 noon    45
SkyHi Kites   jun12 closing 45
;
 Note about code
proc transpose data=stocks out=close let;
 Note about code
   by company;
 Note about code
   id date;
 run;
 Note about code
proc print data=close noobs;
   title 'Closing Prices for Horizon Kites and SkyHi Kites';
run;

Output

 Note about figure
        Closing Prices for Horizon Kites and SkyHi Kites       1

              Company       _NAME_    jun11    jun12

           Horizon Kites    Price       27       30 
           SkyHi Kites      Price       44       45 

Previous Page | Next Page | Top of Page