Resources

General-Form Equations

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

                    SAS Sample Library

        Name: modex06.sas
 Description: Example program from SAS/ETS User's Guide,
              The MODEL Procedure
       Title: General-Form Equations
     Product: SAS/ETS Software
        Keys: nonlinear simultaneous equation models
        PROC: MODEL
       Notes:

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

title1 "General Form Equations for Supply-Demand Model";

proc model outmodel=model;
   var price quantity income unitcost;
   parms d0-d2 s0-s2;
   eq.demand=d0+d1*price+d2*income-quantity;
   eq.supply=s0+s1*price+s2*unitcost-quantity;
run;

data history;
   input year income unitcost price quantity;
datalines;
1976    2221.87    3.31220     0.17903    266.714
1977    2254.77    3.61647     0.06757    276.049
1978    2285.16    2.21601     0.82916    285.858
1979    2319.37    3.28257     0.33202    295.034
1980    2369.38    2.84494     0.63564    310.773
1981    2395.26    2.94154     0.62011    319.185
1982    2419.52    2.65301     0.80753    325.970
1983    2475.09    2.41686     1.01017    342.470
1984    2495.09    3.44096     0.52025    348.321
1985    2536.72    2.30601     1.15053    360.750
;

data assume;
   input year income unitcost;
datalines;
1986    2571.87    2.31220
1987    2609.12    2.45633
1988    2639.77    2.51647
1989    2667.77    1.65617
1990    2705.16    1.01601
;

proc model model=model outmodel=model;

/* estimate the model parameters */
   fit supply demand / data=history outest=est n2sls;
   instruments income unitcost year;
run;

/* produce forecasts for income and unitcost assumptions */
   solve price quantity / data=assume out=pq;
run;

title2 "Parameter Estimates for the System";
proc print data=est;
run;

title2 "Price Quantity Solution";
proc print data=pq;
run;

data goal;
   input year income quantity;
datalines;
1986    2571.87     371.4
1987    2721.08     416.5
1988    3327.05     597.3
1989    3885.85     764.1
1990    3650.98     694.3
;

title2 "Price Unitcost Solution";

/* produce goal-seeking solutions for
     income and quantity assumptions*/
proc model model=model;
   solve price unitcost / data=goal out=pc;
run;

proc print data=pc;
run;