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 (November 2003, week 1)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Wed, 5 Nov 2003 13:46:31 +0100
Reply-To:     "Groeneveld, Jim" <jim.groeneveld@VITATRON.COM>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         "Groeneveld, Jim" <jim.groeneveld@VITATRON.COM>
Subject:      Re: Help with Retain..
Comments: To: "Fehd, Ronald J. (PHPPO)" <rjf2@CDC.GOV>
Content-Type: text/plain; charset="iso-8859-1"

Hi Ron,

Well-done too much! If your code includes a sum statement then an associated RETAIN (with 0-initialization) is implicit and you don't need to explicitly specify it. And maybe: if first.Id then CumCount = 1; may be if first.Id then CumCount = 0; as it is increased to 1 in the next statement already.

And of course your «by ID.» should be «by ID;».

But without further information it remains guessing what the questioner intends.

Regards - Jim. -- . . . . . . . . . . . . . . . .

Jim Groeneveld, MSc. Biostatistician Science Team Vitatron B.V. Meander 1051 6825 MJ Arnhem Tel: +31/0 26 376 7365 Fax: +31/0 26 376 7305 Jim.Groeneveld@Vitatron.com www.vitatron.com

My computer has the solutions, I have the problems.

[common disclaimer]

-----Original Message----- From: Fehd, Ronald J. (PHPPO) [mailto:rjf2@CDC.GOV] Sent: Tuesday, November 04, 2003 20:46 To: SAS-L@LISTSERV.UGA.EDU Subject: Re: Help with Retain..

> From: Nagakumar Sridhar [mailto:nsridhar@ATHEROGENICS.COM] > > In my program, I need to retain the variable > Total for each category. But when I do, the value gets > carried over to the next category.

the retain statement is part of the data structure

you need to RTFM on first. and last. processing which is how you use the data structure in your algorithm.

*data structure: retain CumCount; set SomeDataWithCount; by ID.

*algorithm==processing: if first.Id then CumCount = 1; CumCount + Count; %*this assignment statement style only available with retained var; if last.Id then output;

Ron Fehd the data structure maven CDC Atlanta GA USA RJF2@cdc.gov

RTFM: I'm an engineer, I don't get paid to know, I get paid to know where to look it up. RTFM: Read The Finite Manual.


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