DATA Step, Macro, Functions and more

iterative multiplication/addition

Accepted Solution Solved
Reply
Frequent Learner
Posts: 1
Accepted Solution

iterative multiplication/addition

Hi all,

 

I have built a regegression in SAS, now i have my coeffiients. I now wish to forecast. I have a table with two columns Date and Variable1. I would like to write in sas the ability to create 2 new columns (1, the output of hte regression - what is y), 2 the cumulative balance. )

 

y=alpha+beta(variable1)

 

alpha and beta are defiend. i wish for the first new column to be the values of y and the second column to be (1+y_t)(1+y_(t-1)

 

i'm having trouble figuring out how to write a loop or macro that enables me to actually build out what woudl be quite easy in excel - just the ability to forecast over time. below is an image that outlines what i'm trying to do. assume the following example.

 

Any help would be very much appreciated

 

 


example.png

Accepted Solutions
Solution
‎09-15-2016 09:34 AM
Super User
Posts: 11,343

Re: iterative multiplication/addition

Posted in reply to cwhittelsey

It helps to have some actual data but this is easy with RETAIN for the cumulative value.

You should also examine the concept of Scoring, applying the regression model to another data set.

 

data want;
   set have;
   retain cumulative .
   y= alpah +beta(variable1);
   cumulative = sum(cumulative,y);
run;

View solution in original post


All Replies
Solution
‎09-15-2016 09:34 AM
Super User
Posts: 11,343

Re: iterative multiplication/addition

Posted in reply to cwhittelsey

It helps to have some actual data but this is easy with RETAIN for the cumulative value.

You should also examine the concept of Scoring, applying the regression model to another data set.

 

data want;
   set have;
   retain cumulative .
   y= alpah +beta(variable1);
   cumulative = sum(cumulative,y);
run;
☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 1 reply
  • 198 views
  • 1 like
  • 2 in conversation