Date: Sun, 27 Jul 1997 22:49:09 -0700
Reply-To: Don Stanley <don_stanley@IBM.NET>
Sender: "SAS(r) Discussion" <SAS-L@UGA.CC.UGA.EDU>
From: Don Stanley <don_stanley@IBM.NET>
Organization: SYSWARE Consulting
Subject: Re: Are SAS scripts optimised?
Content-Type: text/plain; charset=us-ascii
oops, damn etc etc, expletive deleted and so on!
yes of course, I was waffling. the expression IF X is true when X is non
zero and not missing. the expression IF NOT X is true if X is zero or X
is missing. Postive or negative numbers are true, zero and missing are
false. Apologies.
Don
Michael R. Gibson wrote:
>
> Don:
> I thought that ( and tested ):
>
> TRUE is anything except zero or missing
> FALSE is zero or missing.
> Therefore:
>
> run stuff-1 when X is not a zero or missing.
>
> always run stuff-2
>
> run stuff-3 only when X is zero or missing.
>
> Tested values: when X = 1 not X was zero. stuff-1 and
> stuff-2
> when X = 0 not X was one or true. stuff-2 and
> stuff-3
> when X = . not X was one or true. stuff-2 and
> stuff-3
> when X = -3 not X was zero. stuff-1 and
> stuff-2
>
> Code used to test:
>
> data _null_;
>
> x = 1; /* this value was changed and code re-run */
> y = not (x);
>
> put x= y=;
>
> if x then put 'Stuff-1';
>
> put 'Stuff-2';
>
> if not(x) then put 'Stuff-3';
> run;
>
> --------------------------------------
> Vicky:
> your "odd" results may be from (like Don said) changing the value of
> X in stuff-1 or stuff-2.
>
> if you X is an expression, did you change the value of ANY variables
> used in the expression in stuff-1 or stuff-2.
>
> You "odd" results are not from code optimization.
>
> ----
> Michael Gibson
>
> Don Stanley wrote:
> >
> > your code should ..
> >
> > - run stuff1 if X is a positive number
> > - always run stuff 2
> > - run stuff3 if X is less than or equal to zero (includes missing)
> >
> > 'odd' results can occur if ..
> >
> > - you don't realise that not x is le 0 and includes missing
> > - stuff 1 or stuff2 modifys X
> >
> > Don
> >
> > Vicky Larmour wrote:
> > >
> > > I've got some code running in a data step that looks something like
> > > this:
> > >
> > > if X then do;
> > > [stuff1]
> > > end;
> > >
> > > [stuff2]
> > >
> > > if not(X) then do;
> > > [stuff3]
> > > end;
> > >
> > > I am specifically relying on the order of execution of these
> > > statements for my code to work. The code isn't working, and something
> > > that just occurred to me is the possibilty that SAS is treating the
> > > code as:
> > >
> > > if X then do;
> > > [stuff1]
> > > end;
> > > else do;
> > > [stuff3]
> > > end;
> > >
> > > [stuff2]
> > >
> > > This would explain the rather strange results I am getting, which I
> > > cannot explain any other way. Does anyone know whether SAS does indeed
> > > try to "optimise" things like this? Could this be my problem?
> > > (If it helps, SAS 6.11 on SunOS 4.1.4)
> > >
> > > Thanks in advance,
> > > Vicky
> > >
> > > ---o0o---o0o---o0o--- Vicky Larmour ---o0o---o0o---o0o---
> > > vicky@merton.logica.co.uk
> > > Standard disclaimer: my opinions, not my employers'.
> >
> > --
> >
===========================================================================
> > Don Stanley Don_Stanley@IBM.NET
> --------- snip -----------
> >
===========================================================================
>
>
------------------------------------------------------------------------------
> Michael R. Gibson The opinions expressed are
> StorageTek, Louisville CO USA those of my own and do not
> michael_gibson@stortek.com reflect those of my
> employer.
>
> To reply to this message remove the NOSPAM from my address.
--
===========================================================================
Don Stanley Don_Stanley@IBM.NET
Ph 0064 021 479 863
Fax 0064 04 386 2038 (Computer fax not always operating)
Director (1 of 4) of SYSWARE Consulting Group, NZ SAS Specialists.
Snail Mail Box 14554
Kilbirnie
Wellington
NEW ZEALAND
Thought for the life ... nah, thinking takes to much effort
Ashleys dad and proud of it!! Especially when he sleeps.
===========================================================================