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 2002, week 1)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Tue, 1 Oct 2002 16:49:31 +0200
Reply-To:     Jim Groeneveld <J.Groeneveld@ITGROUPS.COM>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         Jim Groeneveld <J.Groeneveld@ITGROUPS.COM>
Subject:      Re: If then statement (with data)
Comments: To: Ellen Rains <erains@NERI.ORG>
Content-Type: text/plain

Hi Ellen,

OK, I suddenly understand your Q. Your 2nd condition makes Var5 equal to 1, just as you expect! Subsequently, because your IF statements are independent (not bound by ELSE), your (faulthy) 5th IF statement also has a condition that is true for your data of record 3, and thus Var5 becomes 3, overwriting 1.

I suspect that you did not operationalize your desired dependencies correctly. Just verbalize your dependencies in normal language (English) and try to operationalize them from scratch, making use of both ELSE and DO and END. Do study those statements firstly; it simplifies your code and decreases chances on coding errors a lot.

Regards - Jim. -- Y. (Jim) Groeneveld, MSc IMRO TRAMARKO tel. +31 412 407 070 senior statist./data man. P.O. Box 1 fax. +31 412 407 080 J.Groeneveld@ITGroups.com 5350 AA BERGHEM, NL www.imrotramarko.com

My computer does what I tell it to do; I do tell myself to believe that.

Notice of confidentiality: this e-mail may contain confidential information intended for the addressed recipient only. If you have received this e-mail in error please delete this e-mail and please notify the sender so that proper delivery can be arranged.

> -----Original Message----- > From: Ellen Rains [SMTP:erains@NERI.ORG] > Sent: Tuesday, October 01, 2002 4:16 PM > To: SAS-L@LISTSERV.UGA.EDU > Subject: If then statement (with data) > > I have written the following statements. > > if Var1 eq 12 and Var3 = 1 and Var2 ^= 1 then Var5 = 1; > if Var1 eq 12 and Var4 = 1 and Var2 ^= 1 then Var5=1; > if Var1 eq 12 and Var2 = 1 then Var5=0; > if Var1 eq 12 and Var2 = 2 then Var5 = 1; > if Var1 eq 12 and Var2 = 3 (Var3 ^= 1 or Var4 ^=1) then Var5 = 3;; > if Var1 eq 12 and Var3 = 3 and Var4 = 3 and Var2 =3 then pat2y=3; > if Var1 eq 12 and Var2 = -8 then Var5 = -8; > > Var1 Var2 Var3 Var4 Var5 > 12 2 1 2 1 > 12 2 1 2 1 > 12 3 3 1 3 > 12 3 3 3 3 > 12 -8 -8 -8 -8 > > In the 3rd observation Var5 should = 1 but it = 3.?? Is my logic and > programming correct? > > Thanks


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