LISTSERV at the University of Georgia
Menubar Imagemap
Home Browse Manage Request Manuals Register
Previous (more recent) messageNext (less recent) messagePrevious (more recent) in topicNext (less recent) in topicPrevious (more recent) by same authorNext (less recent) by same authorPrevious page (September 1998, 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 Sep 1998 21:13:07 +0100
Reply-To:     roland.rashleigh-berry@virgin.net
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

data cum; retain arcum 0; set whatever; arcum=arcum+armean; run;

Roland

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


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