Skip to Main Content
Applied Econometrics Using the SAS® System
book

Applied Econometrics Using the SAS® System

by Vivek B. Ajmani
June 2009
Intermediate to advanced content levelIntermediate to advanced
328 pages
8h 42m
English
Wiley-Interscience
Content preview from Applied Econometrics Using the SAS® System

Appendix E

COMPLETE PROGRAMS AND PROC IML ROUTINES

E.1 PROGRAM 1

This program was used in Chapter 2. It is used to analyze Table F3.1 of Greene (2003). In the following data step, we read in the raw data, create a trend variable, T, divide GNP and Invest by CPI, and then scale the transformed GNP and Invest time series so that they are measured in trillions of dollars.

proc import out=invst_equation
datafile="C:\Temp\Invest_Data"
dbms=Excel Replace;
getnames=yes;
run;
data invst_equation;
set invst_equation;
T=_n_;
Real_GNP=GNP/(CPI*10);
Real_Invest=Invest/(CPI*10);
run;
/* The start of Proc IML routines.
*/proc iml;
/* Invoke Proc IML and create the X and Y matrices using the variables T, Real_GNP, and Real_Invest from the SAS data set invst_equation. */
use invst_equation;
read all var {’T’ ’Real_GNP’} into X;
read all var {’Real_Invest’} into Y;
/* Define the number of observations and the number of independent variables. */
n=nrow(X);
k=ncol(X);
/* Create a column of ones to the X matrix to account for the intercept term. */
X=J(n,1,1) ||X;
/* Calculate the inverse of X’X and use this to compute B_Hat */
C=inv(X’ *X);
B_Hat=C *X’ *Y;
/* Compute SSE, the residual sum of squares, and MSE, the residual mean square. */
SSE=y’ *y-B_Hat’ *X’ *Y;
DFE=n-k-1;
MSE=sse/DFE;
/* Compute SSR, the sums of squares due to the model; MSR, the sums of squares due to random error; and the F ratio. */
Mean_Y=Sum(Y)/n;
SSR=B_Hat’ *X’ *Y-n *Mean_Y * *2;
MSR=SSR/k;
F=MSR/MSE;
/* Compute R-Square ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Applied Econometrics with SAS

Applied Econometrics with SAS

Barry K. Goodwin, A. Ford Ramsey, Jan Chvosta

Publisher Resources

ISBN: 9781118210321Purchase book