Missing Values

/*--------------------------------------------------------------

                    SAS Sample Library

        Name: autex04.sas
 Description: Example program from SAS/ETS User's Guide,
              The AUTOREG Procedure
       Title: Missing Values
     Product: SAS/ETS Software
        Keys: autoregression
        PROC: AUTOREG
       Notes:

--------------------------------------------------------------*/

ods graphics on;

title  'Simulated Time Series with Roots:';
title2 ' (X-1.25)(X**4-1.25)';
title3 'With 15% Missing Values';
data ar;
   do i=1 to 550;
      e = rannor(12345);
      n = sum( e, .8*n1, .8*n4, -.64*n5 );  /* ar process  */
      y = n;
      if ranuni(12345) > .85 then y = .;    /* 15% missing */
      n5=n4; n4=n3; n3=n2; n2=n1; n1=n;     /* set lags    */
      if i>500 then output;
   end;
run;

proc autoreg data=ar partial;
   model y = / nlag=(1 4 5) method=ml;
   output out=a predicted=p residual=r ucl=u lcl=l alphacli=.01;
run;

data reshape1;
   set a;
   miss = .;
   if r=. then do;
      miss = p;
      p = .;
   end;
run;

title 'Predicted Values and Confidence Limits';

proc sgplot data=reshape1 NOAUTOLEGEND;
   band x=i upper=u lower=l;
   scatter y=miss x=i/ MARKERATTRS =(symbol=x color=red);
   series y=p x=i/markers MARKERATTRS =(color=blue) lineattrs=(color=blue);
run;