Wednesday, June 8, 2011

Predict a Linear Trend

data sales;
  retain mu 300 std 1000 seed 0;
  format sls_dt mmddyy10.;

  do i=1 to 100;
    sls_dt = '01jan2011'd + i - 1;
    sls_amt = 50*i + mu + std*rannor(seed);
if sls_amt < 0 then sls_amt = 0;
    output;
  end;
run;

proc gplot data = sales;
  plot sls_amt * sls_dt;
run; quit;

proc reg data=sales outest=est;
  model sls_amt = sls_dt;
run; quit;

data _null_;
  set est;
  prediction = intercept + sls_dt * '31dec2011'd;
  put prediction;
run;