Chapter Contents

Previous

Next
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

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
The output data set, CLOSE [HTML Output]
 [Listing Output]


Chapter Contents

Previous

Next

Top of Page

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