FOCUS AREAS

SAS/ETS Web Examples

Testing for Returns to Scale in a Cobb-Douglas Production Function


Contents | Back to Example


data census_data;
   input state $ type $ am;
   datalines;
AL q 28762420000
AL K 2818886000
AL L 544806000
AK q 1153433000
AK K 97292000
AK L 18942000
AZ q 27900974000
AZ K 2593261000
AZ L 245413000
AR q 19392561000
AR K 1410061000
AR L 367624000
CA q 196182882000
CA K 19628560000
CA L 2296334000
CO q 20609367000
CO K 2083882000
CO L 224728000
CT q 27298479000
CT K 1783242000
CT L 315068000
DE q 5209618000
DE K 352875000
DE L 59829000
DC q 170633000
DC K 22435000
DC L 3714000
FL q 39767726000
FL K 2506475000
FL L 555402000
GA q 55426485000
GA K 3408828000
GA L 826574000
HI q 1261303000
HI K 157221000
HI L 18343000
ID q 6383900000
ID K 1157786000
ID L 9069000
IL q 95342475000
IL K 6357175000
IL L 1278831000
IN q 67173341000
IN K 5272833000
IN L 978646000
IO q 28615467000
IO K 1804159000
IO L 356074000
KS q 18987474000
KS K 1178162000
KS L 280314000
KY q 39062786000
KY K 3499977000
KY L 455748000
LA q 27463050000
LA K 3259885000
LA L 256824000
ME q 6698567000
ME K 755909000
ME L 120642000
MD q 18705455000
MD K 1333239000
MD L 218330000
MA q 45132888000
MA K 3615304000
MA L 520200000
MI q 93366860000
MI K 6981199000
MI L 1299481000
MN q 36567010000
MN K 2579422000
MN L 513688000
MS q 17184299000
MS K 1169221000
MS L 360610000
MO q 43071878000
MO K 2834926000
MO L 526652000
MT q 1876897000
MT K 191380000
MT L 27386000
NB q 10460265000
NB K 697928000
NB L 172999000
NV q 3260969000
NV K 249037000
NV L 51573000
NH q 11129674000
NH K 854626000
NH L 134236000
NJ q 49432983000
NJ K 3644389000
NJ L 555738000
NM q 13487517000
NM K 630512000
NM L 56972000
NY q 75858926000
NY K 5074888000
NY L 1049318000
NC q 79790807000
NC K 5207500000
NC L 1192012000
ND q 2008799000
ND K 233693000
ND L 31447000
OH q 112361392000
OH K 7364383000
OH L 1494596000
OK q 17226649000
OK K 1495963000
OK L 241863000
OR q 25100453000
OR K 2899991000
OR L 314114000
PA q 86116509000
PA K 6024692000
PA L 1187997000
RI q 5462493000
RI K 350655000
RI L 103787000
SC q 33343682000
SC K 2769701000
SC L 536612000
SD q 4352357000
SD K 194857000
SD L 64773000
TN q 44527758000
TN K 4620591000
TN L 741421000
TX q 127579894000
TX K 11247496000
TX L 1340712000
UT q 11689959000
UT K 1281331000
UT L 169255000
VT q 4028276000
VT K 714803000
VT L 57719000
VA q 43180687000
VA K 2702950000
VA L 549218000
WA q 31534413000
WA K 2173424000
WA L 424129000
WV q 8980535000
WV K 570564000
WV L 112022000
WI q 54974219000
WI K 3710392000
WI L 829277000
WY q 1030583000
WY K 83569000
WY L 12209000
;
run;


** Manipulate the data for running regression and for plotting data **;
proc sort data=census_data;  
   by state; 
run;

** reg_data is the data set you use for running the regression **;
proc transpose data=census_data out=reg_data
   (rename = (Col1=q Col2=K Col3=L));
   var am;
   by state;
run;

data newdata;
   set census_data;
   lnam=log(am);
   if type='q' then do;
      format lnam dollar15.2;
      end;
   else if type='K' then do;
      format lnam dollar15.2;
      end;
   else if type='L' then do;
      delete;
      end;
run;
** plot_data is the data set you use for plotting the data **;
data plot_data;
   merge newdata (in=a) reg_data (in=b);
   by state;
   if a and b;
   lnl=round(log(L),.01);
   keep state type lnam lnl;
run;

** Create graph **;
proc gplot data=plot_data;
   plot lnam*state=type / nolegend haxis=axis1 vaxis=axis2;
   plot2 lnl*state / vaxis=axis3;
   symbol1 c=blue  i=join v=star;
   symbol2 c=green i=join v=dot;
   symbol3 c=red   i=join v=plus ;
   axis1 label=('State');
   axis2 label=(angle=90 'Value Added, Capital (in log dollars)')
      order=(0 to 30 by 5);
   axis3 label=(angle=90 'Labor (in log hours)')
      order=(0 to 30 by 5);
   title "1997 Production by State";
   footnote1 c=blue  '     *  Capital'
             c=red   '     +  Labor'
             c=green '     .  Value Added';
   footnote2 j=l 'Source: U.S. Census Bureau, Annual Survey of Manufactures,';
   footnote3 j=l '        2001 Geographic Area Statistics';
run; 
quit;
title; footnote;

** Create log variables **;
data model (drop=_name_);
   set reg_data;
   y  = log(q);
   x1 = log(K);
   x2 = log(L);
run;

** Run regression **;
proc reg data=model;
   MODEL_1: model y = x1 x2;
   F_TEST: test x1+x2=1;
run; 
quit;	

** t Test Regression **;
proc reg data=model;
   T_TEST: model y = x1 x2 / covb;
run;  
quit;

** t Test Regression with OUTEST statement **;
proc reg data=model outest=est covout edf;
   T_TEST_OUT: model y = x1 x2 / covb;
run;  
quit;
** Calculate t statistic**;
** Keep the parameter estimates, error degrees of freedom, **;
** variances, and covariance                               **;
data parms;
   set est (where=(_type_='PARMS'));
   keep x1 x2 _edf_;
run;
data varx1;
   set est (where=(_name_='x1'));
   varx1=x1;
   covx1x2=x2;
   keep varx1 covx1x2;
run;
data varx2;
   set est (where=(_name_='x2'));
   varx2=x2;
   keep varx2;
run;
** Calculate the standard error for the denominator, **;
** the t statistic, and the p-values                 **;
data ttest;
   merge parms varx1 varx2;
   se_x1x2 = sqrt(varx1 + varx2 + (2*covx1x2));
   t = (x1 + x2 - 1)/se_x1x2;
   p_inc = 1 - probt(t,_edf_);
   p_dec = probt(t,_edf_);
run;
** Print and view the results **;
 proc print data=ttest;
    var t _edf_ p_inc p_dec;
    title "t statistic and p-values for model";
 run;