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 (October 2008, week 4)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Tue, 28 Oct 2008 09:23:51 -0400
Reply-To:     Gerhard Hellriegel <gerhard.hellriegel@T-ONLINE.DE>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         Gerhard Hellriegel <gerhard.hellriegel@T-ONLINE.DE>
Subject:      Re: Calculating a New Variable based on existing variables in a
              SAS Datafile

unfortunately not possible, if there are other possible values ne 1, e.g 99. Gerhard

On Tue, 28 Oct 2008 09:04:38 -0400, Jack Clark <jclark@HILLTOP.UMBC.EDU> wrote:

>Akshaya, > >If LAG1-LAG100 are numeric variables with a value of 1 or 0, you could >use the MIN function. > >newvar = min(of lag1-lag100); > > > >Jack > > > > >Jack Clark >Senior Research Analyst >phone: 410-455-6256 >fax: 410-455-6850 >jclark@hilltop.umbc.edu > >University of Maryland, Baltimore County >Sondheim Hall, 3rd Floor >1000 Hilltop Circle >Baltimore, MD 21250 > > > > >Confidentiality Notice: This e-mail may contain information that is legally privileged and that is intended only for the use of the addressee (s) named above. If you are not the intended recipient, you are hereby notified that any disclosure, copying of this e-mail, distribution, or action taken in reliance on the contents of this e-mail and/or documents attributed to this e-mail is strictly prohibited. If you have received this information in error, please notify the sender immediately by phone and delete this entire e-mail. Thank you.-----Original Message----- >From: SAS(r) Discussion [mailto:SAS-L@LISTSERV.UGA.EDU] On Behalf Of Jim >Groeneveld >Sent: Tuesday, October 28, 2008 8:24 AM >To: SAS-L@LISTSERV.UGA.EDU >Subject: Re: Calculating a New Variable based on existing variables in a >SAS Datafile > >Hi Akshaya, > >An ARRAY solution: > >ARRAY LagVar Lag1 -- Lag100; * if consecutive in the PDV, or Lag1 - >Lag100; >NewVar = 1; * initialize; >DO I = 1 TO DIM(LagVar); * 100 here; > IF LagVar[i] NE 1 THEN DO; > NewVar = 0; > LEAVE; > END; > DROP I; >RUN; > >Regards - Jim. >-- >Jim Groeneveld, Netherlands >Statistician, SAS consultant >home.hccnet.nl/jim.groeneveld > > >On Tue, 28 Oct 2008 05:14:15 -0700, Akshaya ><akshaya.nathilvar@GMAIL.COM> >wrote: > >>Hi all, >> >>I have a SAS datafile with 100 variables, lag1-lag100. I have to >>calculate a new variable and assign a value of 1, if the value of all >>100 variables is 1; else 0. Is there a simpler way, instead of using >>"IF lag1=1 and lag2=1 and lag3=1 and.... lag100=1". Thanks for any >>suggestions. >> >>Thanks! >>Akshaya


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