|
At 12:52 22/04/99 -0700, Berryhill, Timothy wrote:
>John, If the ob one might consider LAST. is excluded by a WHERE, then the
>previous ob becomes LAST. If it is excluded by an IF, then the results are
>probably bad. Imagine the results of the code below if NAME is missing for
>the last student in a class. Consider the result if the deletion is done in
>a WHERE clause.
>
>DATA SIZE;
> SET GRADES;
> BY CLASS;
> RETAIN NUMSTU;
> IF FIRST.CLASS THEN NUMSTU=0;
> NUMSTU+1;
> IF NAME EQ '' THEN DELETE;
> IF LAST.CLASS THEN OUTPUT;
>RUN;
Tim, yes, I take your point. However, there is actually an ambiguity as to
the programmer's intentions here, isn't there? ... if the intention is that
a student with a 'missing' NAME should be 'counted' (by NUMSTU), then the
"IF NAME EQ .... " statement is actually redundant. If, on the other hand,
the intention was that such students should *not* be 'counted', then there
is more wrong with code than the problem of IF LAST.
Indeed, in general, I would rarely include a conditional DELETE statement in
the same DATA step as a conditional OUTPUT one, in the manner you have above
- that's the sort of situation which is almost bound to get me confused!
Kind Regards,
John
----------------------------------------------------------------
Dr John Whittington, Voice: +44 (0) 1296 730225
Mediscience Services Fax: +44 (0) 1296 738893
Twyford Manor, Twyford, E-mail: medisci@powernet.com
Buckingham MK18 4EL, UK mediscience@compuserve.com
----------------------------------------------------------------
|