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