Date: Wed, 24 Oct 2001 10:14:40 -0700
Reply-To: "Huang, Ya" <ya.huang@PFIZER.COM>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: "Huang, Ya" <ya.huang@PFIZER.COM>
Subject: Re: data transformation puzzle need help.
Content-Type: multipart/alternative;
Yet another one:
data xx;
input Regime ID period volume Rx $;
cards;
1 99 3 3 Th
1 99 6 5 Th
1 99 9 10 CC
2 18 6 15 CC
3 22 12 18 Th
4 32 3 12 CC
4 32 9 5 Th
4 32 12 7 Th
;
data xx;
set xx;
by regime id;
if first.id then n=0;
n+1;
name=compress('p'||put(n,best.)); val=period; output;
name=compress('v'||put(n,best.)); val=volume; output;
keep regime id name val;
proc transpose out=yy (drop=_name_);
by regime id;
var val;
id name;
options nocenter;
proc print;
run;
-----------------------------
Obs Regime ID p1 v1 p2 v2 p3 v3
1 1 99 3 3 6 5 9 10
2 2 18 6 15 . . . .
3 3 22 12 18 . . . .
4 4 32 3 12 9 5 12 7
HTH
Ya Huang
-----Original Message-----
From: John [mailto:jdvona@YAHOO.COM]
Sent: Tuesday, October 23, 2001 4:02 PM
To: SAS-L@LISTSERV.UGA.EDU
Subject: data transformation puzzle need help.
Hi,
AFter a full eight hours of trying to perform this transformation, I
realize that I'm just not up to the task in SAS, and need your wisdom.
I've tried merges, do-loops and a macro w/ no success.
The problem is a forest harvest-scheduling one that requires
transformation. A short example is as follows:
Current format:
Regime ID period volume Rx
1 99 3 3 Th
1 99 6 5 Th
1 99 9 10 CC
2 18 6 15 CC
3 22 12 18 Th
4 32 3 12 CC
4 32 9 5 Th
4 32 12 7 Th
Desired Format of the above example:
Regime ID P1 P2 P3 V1 V2 V3
1 99 3 6 9 3 5 10
2 18 6 15
3 22 12 18
4 32 3 9 12 12 5 7
Thanks in advance,
John
[text/html]