Date: Thu, 9 Nov 2006 15:07:07 -0600
Reply-To: Yu Zhang <zhangyu05@GMAIL.COM>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: Yu Zhang <zhangyu05@GMAIL.COM>
Subject: Re: Question on transposing data
In-Reply-To: <20061109203403.67059.qmail@web32705.mail.mud.yahoo.com>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Jn,
In your original post, you were saying you have 10 variables,each with 2
timepoints data. So I create a fake dataset with 20 variables. The code is
also based on assumpation you have 10 variables.
What your original data loo like? is it 20 variables per line? can you write
back to the list with your data layout and output layout you want?
Yu
On 11/9/06, jn mao <jn_mao@yahoo.com> wrote:
>
> Yu,
>
> Thanks for your help. However, I'm confused about the output. Can you
> explain what are var1 to 10?
>
> Does var1 mean the 1st var with two time point in the column? However, the
> output didn't show the same data.
>
> I have my original data like:
> id aa (var1 at time1) bb(var1at time2) sex
> 1 1.6 1.5 F
> 2 2 2.4 M
>
> after run your pgm, the output is:
> id aa bb var1 sex
> 1 1.6 1.5 0.24 F
> 1 1.6 1.5 0.08 F
> 2 1.6 1.5 0.28 M
> 2 1.6 1.5 0.35 M
>
> Which variable should I use for repeated analysis? Thanks.
>
> Jane
>
> *Yu Zhang <zhangyu05@GMAIL.COM>* wrote:
>
> Jn,
>
> Here is one soultion, not elegent but works.
>
> data have;
> array v {20};
> id=1;
> do sex='F' , 'M';
> do i=1 to 20;
> v(i)=ranuni(1234);
> end;
> output;
> id+1;
> end;
> drop i;
> run;
>
> data need;
> set have;
> array tmp {*} v1-v20;
> array var{10};
> do j=1 to dim(tmp)/10;
> do i=j to dim(tmp) by 2;
> if mod(i,2)=1 then
> var{int(i/2)+1}=tmp(i);
>
> if mod(i,2)=0 then
> var{int(i/2)}=tmp(i);
> end;
> output;
> end;
> drop v1-v20 i j;
> run;
>
>
> HTH
>
> Yu
>
>
>
> On 11/9/06, jn mao wrote:
> >
> > Hello SASLs,
> >
> > I have 10 variables, each variable has two time-point measurements, so
> the
> > total number of variables are 20 on the original datasheet. And for each
> > time point measurement, they have different variable names. Now I need
> to
> > transpose them to the repeated ANOVA analysis, how could I transpose
> them
> > together?
> >
> > For eg of two variables:
> > orignial data format:
> > id aa( var1 at time1) bb (var1at time2) cc( var2 at time1) dd (var2
> > at time2) sex
> > 1 20 22 1.2
> > 1.4 F
> > 2 21 22 0.9
> > 1.2 M
> >
> > The data format I need:
> > id var1 var2 sex
> > 1 20 1.2 F
> > 1 22 1.4 F
> > 2 21 0.9 M
> > 2 22 1.2 M
> >
> >
> > How could I transpose 10 vars together in SAS? Thanks much.
> >
> > Jane
> >
> >
> >
> >
> > ---------------------------------
> > Access over 1 million songs - Yahoo! Music Unlimited.
> >
>
>
> ------------------------------
> Access over 1 million songs - Yahoo! Music Unlimited.<http://pa.yahoo.com/*http://us.rd.yahoo.com/evt=36035/*http://music.yahoo.com/unlimited/>
>
>
|