Date: Thu, 11 Jan 2001 11:38:51 -0800
Reply-To: "Huang, Ya" <ya.huang@AGOURON.COM>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: "Huang, Ya" <ya.huang@AGOURON.COM>
Subject: Re: Need Help with Transpose - Resend
Content-Type: multipart/alternative;
Anna,
It's kind of brute force, but it works:
data xx;
input SCORE GROUP ACCOUNTS BALANCE;
cards;
1 1 25 30
1 2 40 5
2 4 25 4
3 3 11 0
3 1 22 5
3 2 25 54
;
options nocenter;
proc sql;
select distinct score,
sum(accounts*(group=1)) as g1acct,
sum(accounts*(group=2)) as g2acct,
sum(accounts*(group in (3,4))) as g34acct,
sum(balance) as blnc
from xx
group by score
;
-------------------------
SCORE G1ACCT G2ACCT G34ACCT BLNC
------------------------------------------------
1 25 40 0 35
2 0 0 25 4
3 22 25 11 59
HTH
Ya Huang
-----Original Message-----
From: Anna Henson [mailto:anna_henson@YAHOO.COM]
Sent: Thursday, January 11, 2001 11:21 AM
To: SAS-L@LISTSERV.UGA.EDU
Subject: Need Help with Transpose - Resend
Dear SAS-Lers:
I have the following table that I would like to transpose it into a new
table. I have tried many different ways, but I could not do it.
Any help is greatly apreciated.
SCORE GROUP accts BALANCE
1 1 25 30
1 2 40 5
2 4 25 4
3 3 11 0
3 1 22 5
3 2 25 54
I would like to group then transpose to the desired table below
score group-1accts group-2accts group-3+4accts balance
1 25 40 0
35
2 0 0 25
4
3 22 25 11
59
data one;
input score group accounts balance;
cards;
1 1 25 30
1 2 40 5
2 4 25 4
3 3 11 0
3 1 22 5
3 2 25 54
;
run;
Thank you for all your help
Anna Henson
[text/html]