Polynomial Distributed Lags Using %PDL

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

                    SAS Sample Library

        Name: modex05.sas
 Description: Example program from SAS/ETS User's Guide,
              The MODEL Procedure
       Title: Polynomial Distributed Lags Using %PDL
     Product: SAS/ETS Software
        Keys: nonlinear simultaneous equation models
        PROC: MODEL
       Notes:

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

/*--------------------------------------------------------------*/
/*  Generate Simulated Data for a Linear Model with a PDL on X  */
/*        y = 10 + x(6,2) + e                                   */
/*        pdl(x) = -5.*(lg)**2 + 1.5*(lg) + 0.                  */
/*--------------------------------------------------------------*/
data pdl;
   pdl2=-5.; pdl1=1.5; pdl0=0;
   array zz(i) z0-z6;
   do i=1 to 7;
      z=i-1;
      zz=pdl2*z**2 + pdl1*z + pdl0;
      end;
   do n=-11 to 30;
      x  =10*ranuni(1234567)-5;
      pdl=z0*x + z1*xl1 + z2*xl2 + z3*xl3 + z4*xl4 + z5*xl5 + z6*xl6;
      e  =10*rannor(1234567);
      y  =10+pdl+e;
      if n>=1 then output;
      xl6=xl5; xl5=xl4; xl4=xl3; xl3=xl2; xl2=xl1; xl1=x;
      end;
run;

title1 'Polynomial Distributed Lag Example';
title3 'Estimation of PDL(6,4) Model-- No Endpoint Restrictions';

proc model data=pdl;
   parms int;                  /* declare the intercept parameter */
   %pdl( xpdl, 6, 4 )          /* declare the lag distribution */
   y = int + %pdl( xpdl, x );  /* define the model equation */
   fit y / list;               /* estimate the parameters */
run;

title3 'Estimation of PDL(6,4) Model-- Both Endpoint Restrictions';

proc model data=pdl ;
   parms int;                  /* declare the intercept parameter */
   %pdl( xpdl, 6, 4, r=both )  /* declare the lag distribution */
   y = int + %pdl( xpdl, x );  /* define the model equation */
   fit y /list;                /* estimate the parameters */
run;

title3 'Estimation of PDL(6,2) Model -- With XPDL_0 Dropped';

proc model data=pdl list;
   parms int;                  /* declare the intercept parameter */
   %pdl( xpdl, 6, 2 )          /* declare the lag distribution */
   y = int + %pdl( xpdl, x );  /* define the model equation */
   xpdl_0 =0;
   fit y drop=xpdl_0;          /* estimate the parameters */
run;