Date: Mon, 14 Nov 2005 18:09:28 -0500 Reply-To: Arthur Tabachneck Sender: "SAS(r) Discussion" From: Arthur Tabachneck Subject: Re: Transpose/Append the values next to the variables Comments: To: sas-l@uga.edu Richie, If you create a uniqued id, for example a field called counter, you could simply use a slight variant of the code which David had suggested with regard to a similar problem you had posted previously. For example: data b; set a; if mod(_n_,3)=1 then counter+1; run; data c(drop=var3 var4 var5 counter); retain var1 var2; array v{*} var3_1 var4_1 var5_1 var3_2 var4_2 var5_2 var3_3 var4_3 var5_3; do _n_=0 by 1 until(last.counter); set b; by counter; if _n_ <= 2 then do; v{1+3*_n_} = var3; v{2+3*_n_} = var4; v{3+3*_n_} = var5; end; end; run; Art ----------- "Richie" wrote in message news:1132008253.619987.168820@g14g2000cwa.googlegroups.com... > Hi All, > > Here is the data set for reference. > > DATA A > Var1 Var2 Var3 Var4 Var5 > 3846 B002 2341 1351 28.51 > 3846 B002 4655 4564 82.01 > 3846 B002 4567 3548 63.69 > 4323 C004 3215 1235 25.21 > 4323 C004 8974 6542 32.14 > 4323 C004 9875 6524 13.21 > 6547 B002 7854 2454 67.12 > 6547 B002 6542 3214 52.21 > 6547 B002 8754 3541 58.24 > 3221 B002 7451 8745 45.21 > 3221 B002 7541 9875 78.42 > 3221 B002 3285 2415 78.60 > > I have to append the values of Var3 Var4 and Var5 next to Var 1Var2. > This is what the output should look like. > > Var1 Var2 Var3 Var4 Var5 Var3 Var4 Var5 Var3 Var4 Var5 > 3846 B002 2341 1351 28.51 4655 4564 82.01 4567 3548 63.69 > 4323 C004 3215 1235 25.21 8974 6542 32.14 9875 6524 13.21 > 6547 B002 7854 2454 67.12 6542 3214 52.21 8754 3541 58.24 > 3221 B002 7451 8745 45.21 7541 9875 78.42 3285 2415 78.60 > > Please note that the values of Var1 and Var 2 are in the group of > threes but repeats itself in some cases. > > Thanks again, > Richie >

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