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