Date: Mon, 7 Sep 1998 21:13:07 +0100
Sender: "SAS(r) Discussion" <SAS-L@UGA.CC.UGA.EDU>
From: Roland <roland.rashleigh-berry@VIRGIN.NET>
Organization: Wogs at Cause
Subject: Re: I'm an idiot, please help! How to create cummulative variable.
Content-Type: text/plain; charset=us-ascii
retain arcum 0;
Edward Kohl wrote:
> O.K. I'm a beginner, but that's still no excuse for not
> being able to do the most basic SAS operation!! Please
> flame me when you reply.
> I have a varaible, ARMEAN, with 201 observations and all I
> want to do is create a new variable, ARCUM, whose value is
> the sum of all previous ARMEANS values. In other words, I
> want a cumulative value of all previous ARMEANS for each
> So it would look something like this:
> ARMEAN ARCUM
> 1 1
> 2 3
> 3 6
> 4 10
> Sounds easy enough, right? Well, I tried doing this,
> ARCUM = ARMEAN + lag(ARCUM)
> but all I got was a column of missing values. I've also
> tried the 'retain' command to set an intitial value for
> ARCUM but that didn't work either, or I didn't use it
> correctly. I've tried other things as well but I won't
> repeat them here because you'll just laugh at me.
> I know I'm missing something completely obvious, but I'd
> rather embarrass myself on a newsgroup than risk being
> dragged away to a mental institution? Thanks.