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 (March 2009, week 2)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:   Tue, 10 Mar 2009 12:42:39 -0400
Reply-To:   Jake Bee <johbee@GMAIL.COM>
Sender:   "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:   Jake Bee <johbee@GMAIL.COM>
Subject:   Re: A Data Manupulation Problem - Please help ( VERY URGENT)
Comments:   To: SAS_learner <proccontents@gmail.com>
In-Reply-To:   <c2192a610903100826i3f01e4f0wedbaa786330f2339@mail.gmail.com>
Content-Type:   text/plain; charset=ISO-8859-1

I think another approach may be: data test2; set test; lengthg combinat $5; if narco='' and patco='' and sasco='' and zasco='' then do; combinat=''; output; end; else do; if narco=:'y' then do; combinat=vname(narco); output; end; if patco=:'y' then do; combinat=vname(patco); output; end; if sasco=:'y' then do; combinat=vname(sasco); output; end; if zasco=:'y' then do; combinat=vname(zasco); output; end; end;

run;

proc sort data=test2 nodupkey; by patno location combinat; run;

proc print; var patno loc: c:; run;

On Tue, Mar 10, 2009 at 11:26 AM, SAS_learner <proccontents@gmail.com>wrote:

> Hello Tom, > > This might be something close assuming that you do not want missing narco > patco and zasco . If You want them Just change the Proc Transpose . > Somebody > might have better solution later > > > data test ; > Input patno location $ Narco $ Patco $ sasco $ Zasco $; > Datalines ; > 103 leg yes yes yes . > 103 hand yes . yes . > 103 uro . . . . > 103 eye . yes . . > 103 chest . . . yes > 104 leg yes . . . > 104 hand . . yes . > 104 uro . yes yes yes > 104 eye . . . . > 104 chest . . yes . > 104 brain . . . . > ;;; > Run; > Proc Sort data = test Out = Test_Out ; > By patno Location ; > Run; > Proc Transpose data = Test_Out Out = Trans_out (Where = (Col1 = "yes") ); > By patno Location ; > Var Narco Patco sasco Zasco ; > run; > Proc Sort data = Trans_out ; > By patno Location ; > Run; > Data Trans ; > Set Trans_out ; By Patno Location ; > If ^First.Patno and ^First.Location then Location = "" ; > Run; > > > > On Tue, Mar 10, 2009 at 10:58 AM, Tom Smith <need_sas_help@yahoo.com> > wrote: > > > I have a following dataset with six variables ( > > patno, location, narco, patco, sasco, zasco) as below: > > > > patno location narco patco sasco zasco > > ----- -------- ----- ----- ----- ----- > > 103 leg yes yes yes > > 103 hand yes yes > > 103 uro > > 103 eye yes > > 103 chest yes > > 104 leg yes > > 104 hand yes > > 104 uro yes yes yes > > 104 eye > > 104 chest yes > > 104 brain > > > > I have to combine variables narco, patco, sasco, zasco > > (by picking the value 'Yes') to a new variable combinat > > by patno, location; so the result ( final dataset) looks > > as below: > > > > > > patno location combinat > > ----- -------- ------- > > 103 leg narco > > patco > > sasco > > 103 hand narco > > sasco > > 103 uro > > 103 eye patco > > 103 chest zasco > > 104 leg narco > > 104 hand sasco > > 104 uro patco > > sasco > > zasco > > 104 eye > > 104 chest sasco > > 104 brain > > > > > > Thanks a lot for helping me. > > >


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