Getting Started Example for PROC SYSLIN

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

                    SAS Sample Library

        Name: sysgs.sas
 Description: Example program from SAS/ETS User's Guide,
              The SYSLIN Procedure
       Title: Getting Started Example for PROC SYSLIN
     Product: SAS/ETS Software
        Keys: interdependent system
              of linear regression equations
        PROC: SYSLIN
       Notes:

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

data in;
   label q = "Quantity"
         p = "Price"
         s = "Price of Substitutes"
         y = "Income"
         u = "Unit Cost";
   drop i e1 e2;
   p = 0; q = 0;
   do i = 1 to 60;
      y = 1 + .05*i  + .15*rannor(123);
      u = 2          + .05*rannor(123) + .05*rannor(123);
      s = 4 - .001*(i-10)*(i-110) + .5*rannor(123);
      e1 = .15 * rannor(123);
      e2 = .15 * rannor(123);
      demandx = 1 + .3 * y + .35 * s + e1;
      supplyx = -1 - 1 * u + e2 - .4*e1;
      q = 1.4/2.15 * demandx + .75/2.15 * supplyx;
      p = ( - q + supplyx ) / -1.4;
      output;
   end;
run;

/*-- OLS Estimation --*/

proc syslin data=in;
   demand: model q = p y s;
   supply: model q = p u;
run;

/*-- Two-Stage Least Squares Estimation --*/

proc syslin data=in 2sls;
   endogenous  p;
   instruments y u s;
   demand: model q = p y s;
   supply: model q = p u;
run;

/*-- K-Class Estimation --*/

proc syslin data=in k=.5;
   endogenous  p;
   instruments y u s;
   demand: model q = p y s;
   supply: model q = p u;
run;

/*-- Seemingly Unrelated Regression --*/

proc syslin data=in sur;
   demand: model q = p y s;
   supply: model q = p u;
run;

/*-- Three-Stage Least Squares Estimation --*/

proc syslin data=in 3sls;
   endogenous  p;
   instruments y u s;
   demand: model q = p y s;
   supply: model q = p u;
run;

/*-- Full-Information Maximum Likelihood Estimation --*/

proc syslin data=in fiml;
   endogenous  p q;
   instruments y u s;
   demand: model q = p y s;
   supply: model q = p u;
run;

/*-- Reduced-Form 3SLS Estimation --*/

proc syslin data=in 3sls reduced;
   endogenous  p;
   instruments y u s;
   demand: model q = p y s;
   supply: model q = p u;
run;

/*-- 3SLS Estimation with Restrictions --*/

proc syslin data=in 3sls;
   endogenous  p;
   instruments y u s;
   demand: model q = p y s;
   peq015: restrict p = .015;
   supply: model q = p u;
   yeq01u: srestrict demand.y = .01 * supply.u;
run;

/*-- 3SLS Estimation with Tests --*/

proc syslin data=in 3sls;
   endogenous  p;
   instruments y u s;
   demand: model q = p y s;
   test_1: test p = .015;
   supply: model q = p u;
run;

proc syslin data=in 3sls;
   endogenous  p;
   instruments y u s;
   demand: model q = p y s;
   supply: model q = p u;
   stest1: stest demand.y = .01 * supply.u;
run;

/*--- Saving Output Data from 3SLS Estimation ---*/

proc syslin data=in out=pred 3sls;
   endogenous  p;
   instruments y u s;
   demand: model q = p y s;
   output predicted=q_demand;
   supply: model q = p u;
   output predicted=q_supply;
run;

/*-- Producing Plots --*/

proc syslin data=in 2sls out=out;
   endogenous  p;
   instruments y u s;
   demand: model q = p y s;
   output residual=residual_q;
run;

proc sgplot data=out;
   scatter x=p y=residual_q;
   refline 0 / axis=y;
run;

proc sgplot data=out;
   scatter x=y y=residual_q;
   refline 0 / axis=y;
run;

proc sgplot data=out;
   scatter x=s y=residual_q;
   refline 0 / axis=y;
run;