Date: Mon, 7 Jan 2008 13:13:53 -0500
Reply-To: Ya Huang <ya.huang@AMYLIN.COM>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: Ya Huang <ya.huang@AMYLIN.COM>
Subject: Re: Transpose question
data have;
input group result test $ _n _mean _std _max _min;
gr=group*10+result;
cards;
1 0 sod 34 19 10 35 9
1 0 pot 30 55 14 96 25
1 0 chl 93 201 37 307 131
1 0 mag 89 58 16 106 27
1 1 sod 30 55 14 96 25
1 1 pot 89 58 16 106 27
1 1 chl 34 19 10 35 9
1 1 mag 93 201 37 307 131
2 0 sod 33 18 9 34 8
2 0 pot 30 55 14 96 25
2 0 chl 93 201 37 307 131
2 0 mag 89 58 16 106 27
2 1 sod 32 18 8 32 7
2 1 pot 89 58 16 106 27
2 1 chl 30 55 14 96 25
2 1 mag 93 201 37 307 131
;
proc sort;
by test group result;
run;
proc transpose data=have out=need;
by test;
var _n _mean _std _max _min;
id gr;
run;
proc print data=need;
run;
test _NAME_ _10 _11 _20 _21
chl _n 93 34 93 30
chl _mean 201 19 201 55
chl _std 37 10 37 14
chl _max 307 35 307 96
chl _min 131 9 131 25
mag _n 89 93 89 93
mag _mean 58 201 58 201
mag _std 16 37 16 37
mag _max 106 307 106 307
mag _min 27 131 27 131
pot _n 30 89 30 89
pot _mean 55 58 55 58
pot _std 14 16 14 16
pot _max 96 106 96 106
pot _min 25 27 25 27
sod _n 34 30 33 32
sod _mean 19 55 18 18
sod _std 10 14 9 8
sod _max 35 96 34 32
sod _min 9 25 8 7
On Mon, 7 Jan 2008 11:51:16 -0500, sas biology <sasbio@GMAIL.COM> wrote:
>Hello Group,
>
> I have a complicated transposition to do . Could you help me with this?
>
>I have the following data that i got from proc univariate.
>
>*
>
>data
>*have;
>
>input
>group result test $ _n _mean _std _max _min;
>
>cards
>;
>
>1 0 sod 34 19 10 35 9
>
>1 0 pot 30 55 14 96 25
>
>1 0 chl 93 201 37 307 131
>
>1 0 mag 89 58 16 106 27
>
>1 1 sod 30 55 14 96 25
>
>1 1 pot 89 58 16 106 27
>
>1 1 chl 34 19 10 35 9
>
>1 1 mag 93 201 37 307 131
>
>2 0 sod 33 18 9 34 8
>
>2 0 pot 30 55 14 96 25
>
>2 0 chl 93 201 37 307 131
>
>2 0 mag 89 58 16 106 27
>
>2 1 sod 32 18 8 32 7
>
>2 1 pot 89 58 16 106 27
>
>2 1 chl 30 55 14 96 25
>
>2 1 mag 93 201 37 307 131
>
>;
>*
>
>run
>*;
>
>I need to transpose in such a way that the ouyput data should look like
this
>test ds group1/result0 group1/ result1 group2/result0 group2/
>result1
>
>sod n 34 30 33
>32
>sod mean 19 55
>18 18
>sod std 10 14 9
>8
>sod max 35 96 34
>32
>sod min 9
>25 8 7
>
>Similarly for the other three tests.
>
>
>
>
>Thanks .
>
>SB