Date: Thu, 17 Aug 2006 16:09:22 -0400
Reply-To: Florio Arguillas <foa2@CORNELL.EDU>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: Florio Arguillas <foa2@CORNELL.EDU>
Subject: Re: rearrange vars and data
In-Reply-To: <1155841100.101774.97500@i42g2000cwa.googlegroups.com>
Content-Type: text/plain; charset="us-ascii"; format=flowed
Hi Ram,
You can use PROC Transpose. Here's a code using your sample data.
data test;
input id var1 var2 var3;
cards;
1 23 27 28
2 26 21 26
3 29 24 23
4 28 27 28
5 27 29 26
;
proc transpose data = test out = test1 (rename=(_name_=vartext col1=varcode));
by id;
var var1 var2 var3;
run;
HTH,
Florio
At 02:58 PM 8/17/2006, ram.sasha@gmail.com wrote:
>Hi
>I need to rearrange the data.
>eg
>The data is in the following format:
>id var1 var2 var3
>1 23 27 28
>2 26 21 26
>3 29 24 23
>4 28 27 28
>5 27 29 26
>
>I want it to be arranged in this format
>
>id vartxt varcode
>1 var1 23
>1 var2 27
>1 var3 28
>2 var1 26
>2 var2 21
>2 var3 26
>3 var1 29
>3 var2 24
>3 var3 23
>
>and so on.
>Can anyone help me with this?
>
>Thanks
>Ram
Florio Arguillas
Consultant Advisor
Cornell Institute for Social and Economic Research
391 Pine Tree Road
Ithaca, NY 14850
|