data pubexp1;               * create data set;

set datpubexp;

y = ee/p;

x = gdp/p;

w = 1/x;

run;

proc sort;

by x;

 

* part (b) & (d);

 

proc reg;

model y = x/acov;

output out=pubout p=yhat r=ehat;

 

proc plot;

plot y*x='y' yhat*x='*'/overlay;

plot ehat*x;

 

* part (c);

 

data one;

set pubexp;

if _n_ <= 17;

 

proc reg;

model y = x;

 

data two;

set pubexp;

if _n_ >= 18;

 

proc reg;

model y = x;

 

* critcal values for tests;

 

data;

fc = finv(.95,15,15);

tc = tinv(.975,32);

proc print;

 

* GLS via weighted least squares;

 

proc reg data=pubexp1;

model y = x;

weight w;

 

run;