[prev in list] [next in list] [prev in thread] [next in thread]
List: sas-l
Subject: Re: Proc Transpose. Is it possible?
From: Adam Hendricks <ahendrix () AA ! NET>
Date: 1997-08-30 18:00:40
[Download RAW message or body]
In article <34078424.21E7@interlog.com>, rcc@interlog.com says...
>
>Hi.
> I have the following dataset:
>
> OBS TRANS DATE CYCLE1 CYCLE2 CYCLE3
>
> 1 00001 01JAN1996 JAN1996 FEB1996 MAR1996
> 2 00002 01FEB1996 FEB1996 MAR1996 APR1996
> 3 00003 01MAR1996 MAR1996 APR1996 MAY1996
>
>
>
> I would like the final dataset to look like this:
>
> OBS TRANS DATE JAN1996 FEB1996 MAR1996 APR1996 MAY1996
>
> 1 00001 01JAN1996 CYCLE1 CYCLE2 CYCLE3
> 2 00002 01FEB1996 CYCLE1 CYCLE2 CYCLE3
> 3 00003 01MAR1996 CYCLE1 CYCLE2 CYCLE3
>
>
> I would like this dataset cause then I can quickly find which cycle a
>TRANS is at, on any particular date. I've tried PROCC TRANSPOSE but I
>can't seem to get it right. Also I want to avoid a messy dataset step
>routine. Any quick and easy solution? Any help is greatly appreciated.
>Thanks in advance.
>
> Rob.
Try:
data pre;
format trans z5. date cycle1-cycle3 monyy7.;
informat date cycle1-cycle3 date9.;
input trans date cycle1 cycle2 cycle3;
cards;
1 01JAN1996 01JAN1996 01FEB1996 01MAR1996
2 01FEB1996 01FEB1996 01MAR1996 01APR1996
3 01MAR1996 01MAR1996 01APR1996 01MAY1996
;
run;
proc sort data=pre;
by trans date;
run;
proc print data=pre;
title 'Before';
run;
proc transpose data=pre out=temp;
by trans date;
var cycle1-cycle3;
run;
proc transpose data=temp out=post(drop=_name_ _label_);
by trans date;
id col1;
var _name_;
run;
proc print data=post;
title 'After';
run;
Adam Hendricks
TAD Staffing (Boeing)
Seattle, WA
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic