Date: Fri, 5 Aug 2011 16:21:14 -0400
Reply-To: "Viel, Kevin" <kviel@SJHA.ORG>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: "Viel, Kevin" <kviel@SJHA.ORG>
Subject: Re: join variables of the same table lengthwise into a single
variable
In-Reply-To: <F9CCAF280C4449A2BD218C54082191DD@D1871RB1>
Content-Type: text/plain; charset="us-ascii"
Data new ;
Set Old ( Keep = KS
Rename = ( KS = newvar )
)
Old ( Keep = CT
Rename = ( CT = newvar )
)
Old ( Keep = AL
Rename = ( AL = newvar )
)
;
Run ;
I'd suggest putting NH, GA, or TX on top :)
-Kevin
Kevin Viel, PhD
Senior Research Statistician
Patient Safety & Quality
International College of Robotic Surgery
Saint Joseph's Translational Research Institute
Saint Joseph's Hospital
5671 Peachtree Dunwoody Road, NE, Suite 330
Atlanta, GA 30342
(678) 843-6076: Direct Phone
(678) 843-6153: Facsimile
(404) 558-1364: Mobile
kviel@sjha.org
> -----Original Message-----
> From: SAS(r) Discussion [mailto:SAS-L@LISTSERV.UGA.EDU] On Behalf Of Nat
> Wooding
> Sent: Thursday, August 04, 2011 5:55 AM
> To: SAS-L@LISTSERV.UGA.EDU
> Subject: Re: join variables of the same table lengthwise into a single
> variable
>
> If you are not concerned about the order of the obs in the new set, you
> could use Proc Transpose.
>
> Nat Wooding
>
> Data Wide;
> input KS CT AL;
> cards;
> 1 4 7
> 2 5 8
> 3 6 9
> ;
> Proc transpose data = wide out = skinny
> (keep = col1
> rename = (col1 = NewVar));
> by notsorted ks;
> var _numeric_ ;
> run;
>
> * I specified notsorted on the by statement since I wanted it to do a
> transposition on each line and I did not know what the sort order of these
> values would be. This will fail if two succeeding obs have identical KS
> values;
>
>
> -----Original Message-----
> From: SAS(r) Discussion [mailto:SAS-L@LISTSERV.UGA.EDU] On Behalf Of
> Nabaneeta Saha
> Sent: Wednesday, August 03, 2011 10:33 PM
> To: SAS-L@LISTSERV.UGA.EDU
> Subject: join variables of the same table lengthwise into a single
> variable
>
> Hi,
>
> I have a table like this:
> KS CT AL
> 1 4 7
> 2 5 8
> 3 6 9
>
> I want a table where the 3 columns are to be joined lengthwise with a new
> variable:
> newvar
> 1
> 2
> 3
> 4
> 5
> 6
> 7
> 8
> 9
>
> Will I have to split table into three separate datasets and then use the
> set
> statement? Is there any other way to do it (i have more than 60
> variables)?
>
> Thanks!
>
> Nsaha6
Confidentiality Notice:
This e-mail, including any attachments is the
property of Catholic Health East and is intended
for the sole use of the intended recipient(s).
It may contain information that is privileged and
confidential. Any unauthorized review, use,
disclosure, or distribution is prohibited. If you are
not the intended recipient, please delete this message, and
reply to the sender regarding the error in a separate email.
|