|
|
Question about transpose
Hi all,
I have a question about the transpose.
Say I have a data as following:
ID PA1 PA2 PA3 PB1 PB2 PB3
1 29 86 41 24 85 29
2 34 70 31 79 60 8
3 6 31 76 30 88 8
4 68 24 90 30 80 90
5 99 99 74 39 55 67
I would like to transpose it to the following:
ID GROUP PA PB
1 1 29 24
1 2 86 85
1 3 41 29
2 1 34 79
2 2 70 60
2 3 31 8
3 1 6 30
3 2 31 88
3 3 76 8
4 1 68 30
4 2 24 80
4 3 90 90
5 1 99 39
5 2 99 55
5 3 74 67
It is a sample structure of the real data. I am a little concern about
the TRANSPOSE. As I remember, it is not recommended for large data
set, but data step.
Any suggestions?
Thanks,
|
|
0
|
|
|
|
Reply
|
yanjiemaomao (10)
|
3/18/2011 5:29:05 PM |
|
On Mar 18, 10:29=A0am, palapara <yanjiemao...@gmail.com> wrote:
> Hi all,
>
> I have a question about the transpose.
> Say I have a data as following:
>
> ID =A0 =A0 =A0PA1 =A0 =A0 PA2 =A0 =A0 PA3 =A0 =A0 PB1 =A0 =A0 PB2 =A0 =A0=
PB3
> 1 =A0 =A0 =A0 29 =A0 =A0 =A086 =A0 =A0 =A041 =A0 =A0 =A024 =A0 =A0 =A085 =
=A0 =A0 =A029
> 2 =A0 =A0 =A0 34 =A0 =A0 =A070 =A0 =A0 =A031 =A0 =A0 =A079 =A0 =A0 =A060 =
=A0 =A0 =A08
> 3 =A0 =A0 =A0 6 =A0 =A0 =A0 31 =A0 =A0 =A076 =A0 =A0 =A030 =A0 =A0 =A088 =
=A0 =A0 =A08
> 4 =A0 =A0 =A0 68 =A0 =A0 =A024 =A0 =A0 =A090 =A0 =A0 =A030 =A0 =A0 =A080 =
=A0 =A0 =A090
> 5 =A0 =A0 =A0 99 =A0 =A0 =A099 =A0 =A0 =A074 =A0 =A0 =A039 =A0 =A0 =A055 =
=A0 =A0 =A067
>
> I would like to transpose it to the following:
>
> ID =A0 =A0 =A0GROUP =A0 PA =A0 =A0 =A0PB
> 1 =A0 =A0 =A0 1 =A0 =A0 =A0 29 =A0 =A0 =A024
> 1 =A0 =A0 =A0 2 =A0 =A0 =A0 86 =A0 =A0 =A085
> 1 =A0 =A0 =A0 3 =A0 =A0 =A0 41 =A0 =A0 =A029
> 2 =A0 =A0 =A0 1 =A0 =A0 =A0 34 =A0 =A0 =A079
> 2 =A0 =A0 =A0 2 =A0 =A0 =A0 70 =A0 =A0 =A060
> 2 =A0 =A0 =A0 3 =A0 =A0 =A0 31 =A0 =A0 =A08
> 3 =A0 =A0 =A0 1 =A0 =A0 =A0 6 =A0 =A0 =A0 30
> 3 =A0 =A0 =A0 2 =A0 =A0 =A0 31 =A0 =A0 =A088
> 3 =A0 =A0 =A0 3 =A0 =A0 =A0 76 =A0 =A0 =A08
> 4 =A0 =A0 =A0 1 =A0 =A0 =A0 68 =A0 =A0 =A030
> 4 =A0 =A0 =A0 2 =A0 =A0 =A0 24 =A0 =A0 =A080
> 4 =A0 =A0 =A0 3 =A0 =A0 =A0 90 =A0 =A0 =A090
> 5 =A0 =A0 =A0 1 =A0 =A0 =A0 99 =A0 =A0 =A039
> 5 =A0 =A0 =A0 2 =A0 =A0 =A0 99 =A0 =A0 =A055
> 5 =A0 =A0 =A0 3 =A0 =A0 =A0 74 =A0 =A0 =A067
>
> It is a sample structure of the real data. I am a little concern about
> the TRANSPOSE. As I remember, it is not recommended for large data
> set, but data step.
>
> Any suggestions?
>
> Thanks,
I think you'd end up using two proc transpose (one for PA and one for
PB) so you may want to use a datastep anyways, then you can do it in
one step.
|
|
0
|
|
|
|
Reply
|
Reeza
|
3/18/2011 11:21:21 PM
|
|
this is the one way u can do this using arrays.
data r;
input ID PA1 PA2 PA3 PB1 PB2 PB3 ;
cards;
1 29 86 41 24 85 29
2 34 70 31 79 60 8
3 6 31 76 30 88 8
4 68 24 90 30 80 90
5 99 99 74 39 55 67
;
run;
proc transpose data=r out=r1;
by id;
var pa1 pa2 pa3 pb1 pb2 pb3;
run;
data split;
set r;
array s{3} pa1-pa3 ;
array t(3) pb1-pb3;
Subject + 1;
do Time=1 to 3;
pa=s{time};
pb=t{time};
output;
end;
keep id pa time pb ;
run;
|
|
0
|
|
|
|
Reply
|
raju
|
3/19/2011 9:43:13 AM
|
|
|
2 Replies
198 Views
(page loaded in 0.077 seconds)
Similiar Articles: about matrix transpose code - comp.lang.vhdlHi friends, this is ramu. i want a code for matrix transpose code in vhdl ... text - Perhaps you should post your full code and ask a more specific question ... sum without transposing - comp.soft-sys.matlab... Post Question | Groups | ... 2 > 4 > 6 > > How can I do this without needing to transpose A. transpose help - comp.soft-sys.sasVLAN question - Need help !! - comp.dcom.sys.cisco Hi, I'm new to VLAN setup. Can anyone expert help me ? I have 2 x 2950-24 switch setup in my office, they're all under ... Parallel matrix transpose with MPI (mpich2). - comp.parallel.mpi ...... Post Question | Groups | ... inside dynamically by the user instead of a static (fixed) ones, and then transpose ... How to transpose selected rows into columns and sort by one column ...... Post Question | Groups | ... How to transpose selected rows into columns and sort by one column ... reformatting ... how to transpose large matrix? - comp.unix.shellI want to generate a file that contains the transpose of this matrix, and do so ... entries, but of course the OP can define the data structure that is of question. A question about Yen's K Shortest Paths algorithm in Matlab - comp ...how to transpose large matrix? - comp.unix.shell A question about Yen's K Shortest Paths algorithm in Matlab ... how to transpose large matrix? - comp.unix.shell A ... R50 Hard Reset? - comp.sys.laptops.thinkpad... Thinkpad R50 have a hard reset button?.... short of holding the power off switch ... A31 Thinkpad question about bios password's. - comp.sys.laptops ... R50 Hard Reset ... SWITCH expression must be a scalar or string constant - comp.soft ...Hi, everyone. I came across a strange question while I tried to use fzero. For example, if I type X = fzero(@tan,2), the Matlab window will show up t... Data Structure Using Proc Transpose - comp.soft-sys.sas... Post Question | Groups | ... is the problem I am running in to when I try flipping the data using Proc transpose ... Transposing Question - The Trombone Forum - IndexTransposing Question (1/2) > >> indy107: First of all, Thanks everyone for all the replies on my last post. Someone mentioned maturity, I laugh but thank them for the ... Ask.com - What's Your Question?Ask.com is the #1 question answering service that delivers the best answers from the web and real people - all in one place. 7/17/2012 10:34:05 AM
|
|
|
|
|
|
|
|
|