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 (October 2002, week 1)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Mon, 7 Oct 2002 15:19:51 +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: How to count?
Comments: To: "Parent, David" <david.parent@CAPITALONE.COM>
In-Reply-To:  <E17yY75-00015K-00@coumxnn02.netbenefit.co.uk>
Content-Type: text/plain; charset="us-ascii"; format=flowed

At 09:39 07/10/02 -0400, Parent, David wrote (in part):

>I will concede that adding "retain count" may add some value to the >programmer's eye when reading the program and gaining understanding. >However, as initially written (and tested), I believe my implementation of >the counter below will produce the same results with or without the retain >statement. Have you found differently? > > -----Original Message----- >From: Cui, Jinrui [mailto:Jinrui.Cui@cshs.org] > >I just say to add "retain count", like > > > Data temp2; > > Set temp; > retain count; > > By x; > > /*Reset count to zero for each "x group"*/ > > If first.x then count=0; > > Count+1; > > Run;

Yes, you're certainly right. The implied RETAIN which comes from coding the summation statement "Count+1;" means that the same ';result' (value of Count) will result whether or not one has an explicit RETAIN statement. I must confess that I often will include this 'unnecessary' RETAIN statement - for the reason you mention.

If an explicit RETAIN had been included prior to the SET statement (which is the coding practice of many folk), then there would be one slight difference (if you count it as a difference!), in that the variable Count would then be the 'first' variable in the output dataset, not the last 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 ----------------------------------------------------------------


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