Procedure features: |
PROC
TRANSPOSE statement option:
|
|
This example shows how to use values of a variable (ID) to name transposed
variables even when the ID variable has duplicate values.
|
options nodate pageno=1 linesize=64 pagesize=40; |
|
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
; |
|
proc transpose data=stocks out=close let; |
|
by company; |
|
id date;
run; |
|
proc print data=close noobs;
title 'Closing Prices for Horizon Kites and SkyHi Kites';
run; |
|
Closing Prices for Horizon Kites and SkyHi Kites 1
Company _NAME_ jun11 jun12
Horizon Kites Price 27 30
SkyHi Kites Price 44 45
| |
Copyright © 2010 by SAS Institute Inc., Cary, NC, USA. All rights reserved.