Date: Wed, 1 Nov 2000 18:03:54 +0000
Reply-To: Puddin' Man <pudding_man@POSTMARK.NET>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: Puddin' Man <pudding_man@POSTMARK.NET>
Subject: Re: SAS/Base: automatic variable _n_ behavior
Content-Type: text/plain; charset="iso-8859-1"
> so what is wrong with a structure I consider to be very clear and why
> say "(the structure should probably be avoided)" ?
Please note that I didn't say "the structure is wrong" ...
> puddin'man say.......
> ""
> It seems, however, I've run across several programs resembling:
>
> data ...;
> set ...;
> ...
> if <cond1>;
> ...
> if <cond2>;
> ...
> if <condition testing _n_> then <take action>;
> ...
>
> and if folks dealing with such code didn't know when _n_
> incremented, they would likely get into trouble. They may
> anyway (the structure should probably be avoided).
> ""
I dunno that controlling data step iterations by testing
_N_ after subsetting IF's is particularly advisable. If
one is intimate with both the data and the data step
code I suspect there are often better means to the same
intended end. This is, of course, very much a generality.
> I don't expect you have run across any of my code, but the above
> style IMHO wins hands down over the corresponding over-weighty
> nested "if then do end else do end" structures.
I wasn't objecting to subsetting IF's. They are very handy,
very useful.
> It is allways disappointing when testing the end-of-data
> conditions preclude subsetting if statements.
If I understand your statement correctly, I dunno that such
preclusion should ever exist.
Wasn't it Ian that first made a valid point that something like:
data ...;
set <whatever> end=e1;
if <condition>;
if e1 then <action>;
may fail to execute the intended end-of-file action whereas
something like:
data ...;
if e1 then <action>;
set <whatever> end=e1;
if <condition>;
will not ??
> The prerequisite for encouraging use of the "subsetting if" is
> that maintainers of the code understand the principle.
I agree.
> Surely ( like understanding _n_ ) that is not much to ask ?
Well, it shouldn't be. But you've probably noticed that Q's
re behavior of _N_ have been fairly common on sas-l in
recent years. This is evidence that "not everybody understands
it fully".
> Would you want the applications you create to be "enhanced" by
> maintenance programmers who are learning to program ?
Not if I can hep' it. :-)
Prosit,
Puddin'
*******************************************************
*** Puddin' Man *** Pudding_Man@postmark.net *****
******************************************************;