Date: Thu, 22 Mar 2012 20:27:55 +0000
Reply-To: "Schmid, Dennis (CDC/OSELS/SEPDPO) (CTR)" <wfu4@CDC.GOV>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: "Schmid, Dennis (CDC/OSELS/SEPDPO) (CTR)" <wfu4@CDC.GOV>
Subject: Re: Reshape data
In-Reply-To: <CAKepp6qi2B1D+6MRgkQ=m7eTbCUwEzEyXKERu+WFBub15frBxg@mail.gmail.com>
Content-Type: text/plain; charset="us-ascii"
Charlie,
I made one assumption about your name variable in my input statement.
The SAS System 16:15 Thursday, March 22, 2012 7
Obs Name Age Height Weight
1 Alfred 14 69.0 112.5
2 Alice 13 56.5 84.0
3 Barbara 13 65.3 98.0
4 Carol 14 62.8 102.5
5 Henry 14 63.5 102.5
data inpdat;
input @ 'NAME' Name $10. @ 'Age' Age @ 'Height' Height @ 'Weight' Weight ;
cards;
NAME Alfred
Age 14
Height 69
Weight 112.5
NAME Alice
Age 13
Height 56.5
Weight 84
NAME Barbara
Age 13
Height 65.3
Weight 98
NAME Carol
Age 14
Height 62.8
Weight 102.5
NAME Henry
Age 14
Height 63.5
Weight 102.5
;
run; proc print;run;
-----Original Message-----
From: SAS(r) Discussion [mailto:SAS-L@LISTSERV.UGA.EDU] On Behalf Of Charlie Huang
Sent: Thursday, March 22, 2012 3:53 PM
To: SAS-L@LISTSERV.UGA.EDU
Subject: Reshape data
Hi SASLers,
I have a question regarding data reshaping like below. I wonder if there is any good method to do it. Thanks a lot.
I have:
NAME Alfred
Age 14
Height 69
Weight 112.5
NAME Alice
Age 13
Height 56.5
Weight 84
NAME Barbara
Age 13
Height 65.3
Weight 98
NAME Carol
Age 14
Height 62.8
Weight 102.5
NAME Henry
Age 14
Height 63.5
Weight 102.5
I want:
Name Age Height Weight
Alfred 14 69 112.5
Alice 13 56.5 84
Barbara 13 65.3 98
Carol 14 62.8 102.5
Henry 14 63.5 102.5
--
Best regards,
Charlie Huang