```Date: Thu, 9 Nov 2006 12:34:03 -0800 Reply-To: jn mao Sender: "SAS(r) Discussion" From: jn mao Subject: Re: Question on transposing data Comments: To: Yu Zhang In-Reply-To: <445d9dbe0611090948s218465a3wf6b3cbefa6aee18e@mail.gmail.com> Content-Type: text/plain; charset=iso-8859-1 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 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. ```

Back to: Top of message | Previous page | Main SAS-L page