Help using Base SAS procedures

interation (previous line)

Reply
Frequent Contributor
Posts: 81

interation (previous line)


Hello,

 

I need to create a data set like that bellow.

 

where variable "a" need to be the value of the previous value of the variable "c" and so on.

 

b = a * anual/12; 

 

safra a b c anual
1 45.483.247.875 0 45.483.247.875 2,97%
2 45.483.247.875 112.571.038 45.370.676.837 2,97%
3 45.370.676.837 112.292.425 45.258.384.411 2,97%
4 45.258.384.411 112.014.501 45.146.369.910 2,97%
5 45.146.369.910 111.737.266 45.034.632.644 2,97%

 

Thanks

Super User
Posts: 6,751

Re: interation (previous line)

Getting A is straightforward:

 

data want;

set have;

a = lag(c);

if _n_=1 then a=c;

run;

 

Getting B a value of 0 can also be done (but requires a little more coding), if you are computing B as part of this step.  It might depend on what is in ANNUAL.  Is it character, with a value of "2.97%" or is it numeric with a value of 0.297?

Ask a Question
Discussion stats
  • 1 reply
  • 108 views
  • 0 likes
  • 2 in conversation