LISTSERV at the University of Georgia
Menubar Imagemap
Home Browse Manage Request Manuals Register
Previous messageNext messagePrevious in topicNext in topicPrevious by same authorNext by same authorPrevious page (May 2008, week 2)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Thu, 8 May 2008 11:12:10 -0700
Reply-To:     "Terjeson, Mark" <Mterjeson@RUSSELL.COM>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         "Terjeson, Mark" <Mterjeson@RUSSELL.COM>
Subject:      Re: A Short cut transpose question
Comments: To: Tom Smith <need_sas_help@YAHOO.COM>
In-Reply-To:  A<200805081744.m48Al98r004521@malibu.cc.uga.edu>
Content-Type: text/plain; charset="us-ascii"

Hi Tom,

Interesting layout... If that is the exact layout you need, here is a way to do it:

data sample; input Person Blue $ Red $ White $ Full_time $ Part_time $ Terminated $ ; cards; 124 N Y Y Y N N 245 N Y N N Y N 589 Y N N N N Y ; run;

proc transpose data=sample out=temp1a; by Person; var Blue Red White; run; proc transpose data=sample out=temp1b; by Person; var Full_time Part_time Terminated; run;

data temp2a(drop=col1 rename=(_name_=Color)); set temp1a; if col1 eq 'Y'; label _name_=' '; run; data temp2b(drop=col1 rename=(_name_=Status)); set temp1b; if col1 eq 'Y'; label _name_=' '; run;

options missing=''; data result; merge temp2a temp2b; by Person; if lag(Person) eq Person and not first.Person then Person=.; if lag(Status) eq Status and not first.Person then Status=''; run;

Hope this is helpful.

Mark Terjeson Senior Programmer Analyst Investment Management & Research Russell Investments

Russell Investments Global Leaders in Multi-Manager Investing

-----Original Message----- From: SAS(r) Discussion [mailto:SAS-L@LISTSERV.UGA.EDU] On Behalf Of Tom Smith Sent: Thursday, May 08, 2008 10:44 AM To: SAS-L@LISTSERV.UGA.EDU Subject: A Short cut transpose question

I have a following dataset:

Person Blue Red White Full-time Part-time Terminated ------------------------------------------------------------------- 124 N Y Y Y N N 245 N Y N N Y N 589 Y N N N N Y

Need to combine the variables (Blue, Red, White) to a new variable named Color and variables (Full Time, part time and terminated) to a new variable named Status and the new dataset will look like as follows ( also all the transpose I need to do in as short as possible):

Person Color Status --------------------------------

124 Red Full-time White 245 Red Part-Time

589 Blue Terminated

Thanks you so much


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