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 (May 2002, week 3)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:   Tue, 21 May 2002 12:33:28 -0700
Reply-To:   Cassell.David@EPAMAIL.EPA.GOV
Sender:   "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:   "David L. Cassell" <Cassell.David@EPAMAIL.EPA.GOV>
Subject:   Re: a small question?
Content-type:   text/plain; charset=us-ascii

amy <amywang11790@YAHOO.COM> wrote: > I have 4 columns: a1 b1 c1 d1 in dataset test1 > a1 b1 c1 d1 > 1 2 3 2 > ......... > > How can I generate following data set? > a1 a2 b1 b2 c1 c2 d1 d2 > 1 1 2 3 3 6 2 8 > ......... > > i.e. > a2=a1 > b2=a1+b1; > c2=b1+c1; > d2=c1+d1;

You can do this exactly the way you wrote it.

data test2; set test1; a2=a1; b2=a1+b1; c2=b1+c1; d2=c1+d1; run;

However, it looks like you are trying to perform some sort of lag function. Are you aware that SAS has lag functions available in the data step [assuming that your numbers are values of a single variable, going record-by-record]? Without more information on what you *really* want to achieve [the big picture, not a simple formula] we really cannot tell you whether you are doing this the hard way or not.

HTH, David -- David Cassell, CSC Cassell.David@epa.gov Senior computing specialist mathematical statistician


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