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 (April 1999, week 4)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:   Thu, 22 Apr 1999 21:29:41 +0100
Reply-To:   John Whittington <medisci@POWERNET.COM>
Sender:   "SAS(r) Discussion" <SAS-L@UGA.CC.UGA.EDU>
From:   John Whittington <medisci@POWERNET.COM>
Subject:   Re: The WHERE statement does not work for rawdata
Comments:   To: "Berryhill, Timothy" <TWB2@PGE.COM>
Content-Type:   text/plain; charset="us-ascii"

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 ----------------------------------------------------------------


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