Date: Tue, 1 Oct 2002 15:28:59 +0100
Reply-To: John Whittington <John.W@MEDISCIENCE.CO.UK>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: John Whittington <John.W@MEDISCIENCE.CO.UK>
Subject: Re: If then statement (with data)
In-Reply-To: <E17wNox-0005iQ-00@coumxnn02.netbenefit.co.uk>
Content-Type: text/plain; charset="us-ascii"; format=flowed
At 10:16 01/10/02 -0400, Ellen Rains wrote:
>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?
In terms of the statements you have written, 3 would appear to be the
correct answer, since the fifth of your IF...THEN statements is
'true'. Why do you think the answer should be 1? If you expect all
subsequent IF...THEN statements to be skipped after one has proved 'true',
then you need to insert 'ELSE' at the start of all your IF....THEN
statements other than the first one.
Kind Regards,
John
----------------------------------------------------------------
Dr John Whittington, Voice: +44 (0) 1296 730225
Mediscience Services Fax: +44 (0) 1296 738893
Twyford Manor, Twyford, E-mail: John.W@mediscience.co.uk
Buckingham MK18 4EL, UK mediscience@compuserve.com
----------------------------------------------------------------
|