Procedure features: |
BY
statement |
VAR statement |
|
Other features: |
Data set option:
|
This
example illustrates transposing BY groups and selecting
variables to transpose.
|
options nodate pageno=1 linesize=80 pagesize=40; |
|
data fishdata;
infile datalines missover;
input Location & $10. Date date7.
Length1 Weight1 Length2 Weight2 Length3 Weight3
Length4 Weight4;
format date date7.;
datalines;
Cole Pond 2JUN95 31 .25 32 .3 32 .25 33 .3
Cole Pond 3JUL95 33 .32 34 .41 37 .48 32 .28
Cole Pond 4AUG95 29 .23 30 .25 34 .47 32 .3
Eagle Lake 2JUN95 32 .35 32 .25 33 .30
Eagle Lake 3JUL95 30 .20 36 .45
Eagle Lake 4AUG95 33 .30 33 .28 34 .42
; |
|
proc transpose data=fishdata
out=fishlength(rename=(col1=Measurement)); |
|
var length1-length4; |
|
by location date;
run; |
|
proc print data=fishlength noobs;
title 'Fish Length Data for Each Location and Date';
run; |
|
Fish Length Data for Each Location and Date 1
Location Date _NAME_ Measurement
Cole Pond 02JUN95 Length1 31
Cole Pond 02JUN95 Length2 32
Cole Pond 02JUN95 Length3 32
Cole Pond 02JUN95 Length4 33
Cole Pond 03JUL95 Length1 33
Cole Pond 03JUL95 Length2 34
Cole Pond 03JUL95 Length3 37
Cole Pond 03JUL95 Length4 32
Cole Pond 04AUG95 Length1 29
Cole Pond 04AUG95 Length2 30
Cole Pond 04AUG95 Length3 34
Cole Pond 04AUG95 Length4 32
Eagle Lake 02JUN95 Length1 32
Eagle Lake 02JUN95 Length2 32
Eagle Lake 02JUN95 Length3 33
Eagle Lake 02JUN95 Length4 .
Eagle Lake 03JUL95 Length1 30
Eagle Lake 03JUL95 Length2 36
Eagle Lake 03JUL95 Length3 .
Eagle Lake 03JUL95 Length4 .
Eagle Lake 04AUG95 Length1 33
Eagle Lake 04AUG95 Length2 33
Eagle Lake 04AUG95 Length3 34
Eagle Lake 04AUG95 Length4 .
| |
Copyright © 2010 by SAS Institute Inc., Cary, NC, USA. All rights reserved.