SAS Basics

Houston H. Stokes

1/23/2019 11:47 AM

Goal: This document gives SAS basics. It is not intended to be a complete reference. Using cut and paste you will be able to learn enough SAS to do most econometric tasks. A number of key econometric tasks have sample jobs (obtained from SAS) that ca be studied. Further detail on the many SAS commands can be found in SAS Manuals, which are on line at UIC at:

Problem Sets: There are number of sample setups that should be tested and modified top test your mastery of basic SAS.

There are detailed examples of how to load data in SAS. The final examples show using SAS as a front-end for another software were system, here b34s, and in turn using B34S as a front-end to SAS as well as applications. It is suggested that these examples be copied and tried and modified as needed.

SAS Help

SAS is a procedure driven system that consists of a DATA step that loads data and a number of PROC steps that do various useful tasks. Each SAS PROC or DATA step in SAS contains sentences ending with ;. The first sentence in the paragraph begins with the key word DATA or PROC. The last sentence in the paragraph should be RUN;.

The code for a number of tasks is given below.

Steps to run SAS:

1. Edit a file using notepad (on pc) or pico (on unix) of the form name.sas that will contain the SAS script. The suffix must be .sas!

2. Run the sas script by typing

sas name

this will make a file name.log where any errors will be shown and a file name.lst where the output is placed.

3. Open name.log and name.lst with your editor and see what has occurred. Fix bugs and retry job.

Basics:

Assume data is in a txt file called mydat.dat and is in columns of numbers. If you do not have such a file place the below listed data into such as file.

1 19.25 0.204 0.035 1 47 1.10 51.2 0.321 1

2 7.53 0.327 0.081 1 58 .92 48.5 0.224 1

3 5.66 0.401 0.012 1 82 1.72 50.8 0.127 0

4 3.21 0.318 0.070 1 100 2.18 54.4 0.063 0

5 2.80 0.350 0.062 1 222 1.75 52.4 0.021 0

6 1.41 0.283 0.100 1 164 2.26 56.7 0.027 0

7 6.18 0.204 0.050 1 161 2.07 54.6 0.139 1

8 12.15 0.232 0.054 1 70 1.43 52.7 0.218 1

9 1.34 0.199 0.086 1 219 1.92 52.3 0.008 0

10 3.71 0.138 0.0 0 81 1.82 53.0 0.012 0

11 5.35 0.142 0.018 1 209 2.34 55.4 0.076 0

12 4.72 0.118 0.045 1 182 2.12 53.5 0.299 0

13 3.81 0.207 0.040 1 185 1.81 51.6 0.040 0

14 10.44 0.189 0.045 1 104 1.35 48.5 0.069 1

15 9.58 0.124 0.125 1 126 1.26 49.3 0.330 1

16 1.02 0.210 0.060 1 192 2.07 53.9 0.017 0

17 7.52 0.227 0.055 1 95 2.04 55.7 0.166 1

18 1.31 0.167 0.0 0 245 1.55 51.2 0.003 0

19 1.67 0.120 0.0 0 97 1.89 54.0 0.010 0

20 7.07 0.139 0.041 1 177 1.68 52.2 0.076 0

21 11.79 0.272 0.063 1 125 0.76 51.1 0.454 1

22 2.71 0.125 0.0 0 56 1.96 54.0 0.032 0

23 13.21 0.235 0.086 1 85 1.29 55.0 0.266 1

24 3.48 0.108 0.040 1 199 1.81 52.9 0.018 0

25 0.81 0.672 0.0 0 298 1.72 53.7 0.038 0

26 2.32 0.357 0.030 1 145 2.39 55.8 0.067 0

27 3.47 0.592 0.029 1 78 1.68 50.4 0.075 0

28 8.31 0.225 0.400 1 144 2.29 58.8 0.064 0

29 1.57 0.267 0.126 1 178 2.34 54.5 0.065 0

30 4.13 0.164 0.122 1 146 2.21 53.5 0.065 0

31 3.84 0.128 0.091 1 132 1.42 48.8 0.090 1

32 1.83 0.287 0.075 1 98 1.97 54.5 0.016 0

33 3.54 0.210 0.069 1 120 2.12 52.1 0.061 0

34 1.11 0.342 0.0 0 148 1.90 56.0 0.019 0

35 8.90 0.133 0.216 1 123 1.15 56.2 0.389 1

36 1.27 0.241 0.100 1 282 1.70 53.3 0.037 0

37 15.26 0.167 0.038 1 79 1.24 50.9 0.161 1

38 11.15 0.252 0.040 1 34 1.55 53.2 0.127 1

39 1.74 0.418 0.0 0 104 2.04 51.7 0.017 0

40 11.98 0.282 0.032 1 91 1.59 54.3 0.222 1

41 3.04 0.194 0.086 1 199 2.07 53.7 0.026 0

42 .85 0.378 0.0 0 101 2.00 54.7 0.012 0

43 2.83 0.757 0.033 1 109 1.84 47.0 0.057 1

44 2.89 0.357 0.0 0 117 2.04 56.9 0.022 0

On smith.econ.uic.edu this data is in

'/usr/local/lib/hhsfiles/sasdata/murder.dat'

If you run from smith, the infile sentence must be

infile '/usr/local/lib/hhsfiles/sasdata/murder.dat';

Notice there are 10 columns. This data is from the McManus Death penalty study and concerned with a study of the deterrence of capital punishment. The data is saved in 'murder.dat' and is discussed in Stokes (1991, 1997) and in Maddala 'Introductory Econometrics' (1988) pages 279 -283: The columns are listed below using the optional sas label feature.

The SAS data step is coded as:

data murder;

infile 'murder.dat';

INPUT N M PC PX D1 T Y LF NW D2 ;

label N = 'Observation Number ';

label M = 'Murder rate per 100,000 FBI est 1950 ';

label PC = '# convictions / Number of Murders 1950 ';

label PX = 'Av. # executions 46-50/# convictions ';

label Y = 'Median family income (49) * 1000 ';

label LF = 'Labor force participation in 1950 in % ';

label NW = 'Proportion of population nonwhite ';

label D2 = 'Dummy variable. 1 for southern states ';

label D1 = 'Dummy. 1=> state has capital punish. ';

label T = 'Median time served convicted murders ';

label D3 = '0=>d1=0,d3=1,1=>d1=1, 2+>PX GE .1 ';

* now build data d3;

d3=0.0;

IF PX GE .1 then d3=1.;

d3 = D1+D3 ;

run;

proc means; run;

* optional listing ;

* proc print; run;

* D1 = F( ) LOGIT/PROBIT , PX = F( ) TOBIT ;

SAS output will be:

The MEANS Procedure

Variable Label N Mean Std Dev Minimum

ƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒ

N Observation Number 44 22.5000000 12.8452326 1.0000000

M Murder rate per 100,000 FBI est 1950 44 5.4036364 4.4634673 0.8100000

PC # convictions / Number of Murders 1950 44 0.2605000 0.1417184 0.1080000

PX Av. # executions 46-50/# convictions 44 0.0603409 0.0686291 0

D1 Dummy. 1=> state has capital punish. 44 0.7954545 0.4080325 0

T Median time served convicted murders 44 136.5227273 61.6043220 34.0000000

Y Median family income (49) * 1000 44 1.7809091 0.3960786 0.7600000

LF Labor force participation in 1950 in % 44 53.0659091 2.4800547 47.0000000

NW Proportion of population nonwhite 44 0.1055909 0.1139929 0.0030000

D2 Dummy variable. 1 for southern states 44 0.3409091 0.4794950 0

D3 0=>d1=0,d3=1,1=>d1=1, 2+>PX GE .1 44 0.9545455 0.6082589 0

ƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒ

Variable Label Maximum

ƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒ

N Observation Number 44.0000000

M Murder rate per 100,000 FBI est 1950 19.2500000

PC # convictions / Number of Murders 1950 0.7570000

PX Av. # executions 46-50/# convictions 0.4000000

D1 Dummy. 1=> state has capital punish. 1.0000000

T Median time served convicted murders 298.0000000

Y Median family income (49) * 1000 2.3900000

LF Labor force participation in 1950 in % 58.8000000

NW Proportion of population nonwhite 0.4540000

D2 Dummy variable. 1 for southern states 1.0000000

D3 0=>d1=0,d3=1,1=>d1=1, 2+>PX GE .1 2.0000000

ƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒ

By using the SAS include command we can keep loading the data and do other operations such as regression, probit, etc. without having to keep these data loading commands in our file.

On smith the file murder.sas can be run with the commands:

%include '/usr/local/lib/hhsfiles/sasdata/murder.sas';

after which other SAS commands can be added. For example on PC:

%include 'c:\sas_data\murder.sas';

* Warning. The probut is -1*usual setup;

proc probit ;

class d1;

model d1 = t y lf nw / d=normal itprint;

Title 'Probit Models for Murder Data';

proc probit;

class d1;

model d1 = t y lf nw / d=logistic itprint;

Title 'Logistic Models for Murder Data';

Loading the data when more than one observation is on a line:

The file gas.dat contains 296 observations on n, gasin and gasout where

More that one observation is on the line. The first few lines are:

1 -0.109 53.8 2 0.000 53.6 3 0.178 53.5 4 0.339 53.5

5 0.373 53.4 6 0.441 53.1 7 0.461 52.7 8 0.348 52.4

The below listed code uses the @@ read option that will tell SAS to keep reading on the same card (line).

data gas;

infile 'gas.dat';

input n gasin gasout @@;

label gasin = 'Gasin Data from Box-Jenkins';

label gasout = 'Gasout Data from Box-Jenkins';

run;

proc means; run;

The above code is in gas.sas on smith.

It can be run with

%include '/usr/local/lib/hhsfiles/sasdata/gas.sas';

Loading the data in a file:

If the data file is small, it can be included in the data loading step as follows:

data test;

input age value;

cards;

1 1995

3 875

6 695

10 345

5 595

2 1795

;

run;

proc means; run;

proc print; run;

proc reg; model value = age;

run;

Note that there is no INFILE statement.

SAS Datasets

SAS has the ability of having multiple datasets current at the same time. The below listed code contains two SAS datasets TEST1 and TEST2. Dataset TEST1 contains two series, TEST2 has three series. The lines

data test2;

set test1;

tell sas to open a new dataset but place the series that were in test1 in this dataset. The goal is to build a new variable.

data test1;

input age value;

cards;

1 1995

3 875

6 695

10 345

5 595

2 1795

;

run;

data test2;

set test1;

agesq=age*age;

run;

proc means data=test1; run;

proc means data=test2; run;

SAS will produce permanent datasets on disk.

Assume data on X and Y are in a file 'sasdata.dat' on a PC. The below listed job will load the DATA and make a SAS dataset jj.sd2 in subdirectory C:\junk

libname test 'c:\junk' ;

data test.jj;

infile 'c:\junk\sasdata.dat';

input x y;

proc means;

This can be read with the SAS job

libname test 'c:\junk';

proc print data=test.jj;

Moving Datasets Across Different Computers

A SAS command file such as test.sas can be edited with an editor or moved freely from one type of computer to another.

The next four SAS jobs illustrate the SAS export facility on a

PC. Control file one loads the GAS data into a SAS file c:\junk\funny.sd2.

Not all observations are shown. Note the two level name on the SAS data step.

libname test 'c:\junk';

data test.funny;

input TIME GASIN GASOUT CONSTANT ;

label GASIN = "Input gas rate in cu. ft / min ";

label GASOUT = "Percent CO2 in outlet gas ";

cards;

1.000 -0.10900000 53.800 1.00

2.000 0.00000000 53.600 1.00

3.000 0.17800000 53.500 1.00

4.000 0.33900000 53.500 1.00

5.000 0.37300000 53.400 1.00

6.000 0.44100000 53.100 1.00

7.000 0.46100000 52.700 1.00

8.000 0.34800000 52.400 1.00

......

295.0 -0.18200000 57.300 1.00

296.0 -0.26200000 57.000 1.00

;

PROC MEANS;

The next job reads the SAS internal SD2 file c:\junk\funny.sd2 and calculates

means.

libname test 'c:\junk';

proc means data=test.funny; run;

The next job will take the SAS SD2 file and make an export file

c:\junk\export.dat. This file can be moved as a binary file to the new computer.

libname misc 'c:\junk';

libname alldata xport 'c:\junk\export.dat';

proc copy in=misc out=alldata memtype=data; run;

The final job will rebuild the SD2 SAS file c:\junk\funny.sd2 from the SAS export file c:\junk\export.dat. These examples were tested using PC SAS version 6.12.

* The name here is the pc or unix directory ;

libname misc 'c:\junk' ;

* The dataset here indicates the export file name ;

libname alldata xport 'c:\junk\export.dat';

proc copy in=alldata out=misc; run;

Missing Data

SAS has a missing data capability. SAS will read . as a

missing value and all SAS procedures will ignore this value. The way that SAS has been programmed has caused some confusion. Assume the following SAS job

data test1;

input age value make;

cards;

1 1995 0

3 875 1

6 695 0

10 345 0

5 595 1

2 1795 0

. 1900 1

8 785 .

;

run;

proc reg;

model value = age;

model value = make;

run;

proc reg;

model value = age;

run;

proc reg;

model value = make;

run;

If would appear that the user has run the same two regression two times.

However, this is not the case. In the first call to proc reg; SAS will drop two observations since if both value and make are not missing, then two observations must be dropped. The second and third call to proc reg will have one more observation since that is the maximum number possible. This “feature” of SAS makes it difficult to compare regressions when there are missing data unless all

regression are run at one time or the data file is explicitly built to remove missing data.

Lags in SAS

The following job will load the gas data and run a GLS model of order 1 using various procedures although it is not needed here:

%include 'gas.sas';

data new;

set;

gasin_1 = lag1(gasin);

gasin_2 = lag2(gasin);

gasin_3 = lag3(gasin);

gasin_4 = lag4(gasin);

gasin_5 = lag5(gasin);

gasin_6 = lag6(gasin);

gasout_1 = lag1(gasout);

gasout_2 = lag2(gasout);

gasout_3 = lag3(gasout);

gasout_4 = lag4(gasout);

gasout_5 = lag5(gasout);

gasout_6 = lag6(gasout);

run;

* OLS ;

proc reg;

model gasout = gasout_1 gasout_2 gasout_3

gasout_4 gasout_5 gasout_6

gasin_1 gasin_2 gasin_3

gasin_4 gasin_5 gasin_6;

* test if these two coef are significant;

test1: test gasout_1=0, gasout_2=0;

* gls ;

proc autoreg;

model gasout = gasout_1 gasout_2 gasout_3

gasout_4 gasout_5 gasout_6

gasin_1 gasin_2 gasin_3

gasin_4 gasin_5 gasin_6 /

maxit = 2000 method=uls nlag=1; run;

proc autoreg;

model gasout = gasout_1 gasout_2 gasout_3

gasout_4 gasout_5 gasout_6

gasin_1 gasin_2 gasin_3

gasin_4 gasin_5 gasin_6 /

maxit = 2000 method=ml nlag=1; run;

proc autoreg;

model gasout = gasout_1 gasout_2 gasout_3

gasout_4 gasout_5 gasout_6

gasin_1 gasin_2 gasin_3

gasin_4 gasin_5 gasin_6 /

maxit = 2000 method=uls nlag=1; run;

proc autoreg;

model gasout = gasout_1 gasout_2 gasout_3

gasout_4 gasout_5 gasout_6

gasin_1 gasin_2 gasin_3

gasin_4 gasin_5 gasin_6 /

maxit = 2000 method=yw nlag=1; run;

SAS IF statements:

If statements in SAS are of the form:

if x = y then kk=1.0;

if y < K then;

v=1.0;

q=2.0;

endif;

The SAS DATA step allows the user to easily subset the data and to build almost any structure. A large number of data building commands are available. Many people think that the data handling capability of SAS is the most valuable feature of the system.

Useful SAS Commands

PROC SORT;

BY TEST;

RUN;

Calling B34S under SAS

The SAS system has extensive and very powerful data building capability. It can be used to build data and then branch to another program such as B34S. The below listed job shows how to call b34s from SAS:

* Simple job showing a branch from SAS to B34S ;

* One control file is built with data in the file;

%include 'c:\b34slm\cb34sm.sas';

data junk;

input x y;

cards;

11 22

33 44

55 66

99 77

77 88

;

proc means;

* ;

* Clean files ********************************** ;

* ;

options noxwait;

run;

data _null_;

command ='erase myjob.b34';

call system(command);

* ;

* End of clean step **************************** ;

* ;

* Place B34S commands next after %readpgm ;

%readpgm

cards;

b34sexec list$ var x$

b34seend$

b34sexec regression$

model y = x$

b34seend$

b34sexec rr$ model y=x$ b34seend$

b34sexec describe$ b34seend$

b34sexec reg$ model y=x$ b34seend$

b34sexec options dispmoff$ b34srun$

;

run;

%cb34sm(data=junk, var=x y, u8='myjob.b34',

u3='myjob.b34',

options=dropmiss)

options noxwait;

run;

With this setup the user must run the file myjob.b34 which contains b34s control

The next sample shows b34s running under SAS.

In this job SAS runs the b34s and copies results into myjob.log and myjob.out.

* Simple job showing a branch from SAS to B34S;

* One control file is built with data in the file;

%include 'c:\b34slm\cb34sm.sas';

data junk;

input x y;

cards;

11 22

33 44

55 66

99 77

77 88

;

proc means;

* ;

* Clean files ********************************** ;

* ;

options noxwait;

run;

data _null_;

command ='erase myjob.b34';

call system(command);

* ;

* End of clean step **************************** ;

* ;

* Place B34S commands next after %readpgm ;

%readpgm

cards;

b34sexec list$ var x$

b34seend$

b34sexec regression$

model y = x$

b34seend$

b34sexec rr$ model y=x$ b34seend$

b34sexec describe$ b34seend$

b34sexec reg$ model y=x$ b34seend$

b34sexec options dispmoff$ b34srun$

;

run;

%cb34sm(data=junk, var=x y, u8="myjob.b34",

u3="myjob.b34",

options=dropmiss)

options noxwait;

run;

* ;

* This step calls b34s and copies files ;

* ;

data _null_;

command ='c:\b34slm\b34slf95.exe myjob.b34';

call system(command);

command ='copy b34s.log myjob.log';

call system(command);

command ='copy b34s.out myjob.out';

call system(command);

run;

endsas;

Discussion of the commands in the job.

1. The below listed command loads the SAS macro cb34sm to process the

SAS/B34S link in the usual manner.

%include 'c:\b34slm\cb34sm.sas';

2. Before loading the b34s control files the next series of

commands erases any jobs of the same name

* ;

* Clean files ********************************** ;

* ;

options noxwait;

run;

data _null_;

command ='erase myjob.b34';

call system(command);

* ;

* End of clean step **************************** ;

* ;

3. Next the user must place all B34S commands after the

SAS macro %readpgm. Note the last b34s command

b34sexec options dispmoff$ b34seend$

turns off the display manager under windows 95 /NT. If this command is not used, B34S will process all commands and return to the display manager.

* ;

* Place B34S commands next after %readpgm ;

%readpgm

cards;

b34sexec list$ var x$

b34seend$

b34sexec regression$

model y = x$

b34seend$

b34sexec rr$ model y=x$ b34seend$

b34sexec describe$ b34seend$

b34sexec reg$ model y=x$ b34seend$

b34sexec options dispmoff$ b34srun$

;

run;

%cb34sm(data=junk, var=x y, u8='myjob.b34',

u3='myjob.b34',

options=nohead)

options noxwait;

run;

4. Steps 1-3 have made the b34s command file myjob.b34

If the user wants to execute b34s under SAS, add the following

commands to the job.

* ;

* This step calls b34s and copies files ;

* ;

data _null_;

command ='c:\b34slm\b34sw.exe myjob.b34';

call system(command);

command ='copy b34s.log myjob.log';

call system(command);

command ='copy b34s.out myjob.out';

call system(command);

run;

endsas;

The next example places b34s commands in one file and data in another. It should be used for large datasets since in this case it is not desirable to have the data in the command file. The control file is myjob.b34

B34S Calling SAS

The next sample job shows B34S loading the gas data and calling SAS. SAS

output is copied back into the b34s output file. Note that B34S is

reading from a file gas.dat. The linux file name is turned off.

/$ Loads B34S data in sas command file TESTSAS.SAS

/$ User can optionally add SAS commands after PGMCARDS$

/; Shows autoreg, arima, VAR SAS commands

/$ b34sexec options ginclude('gas.b34'); b34srun;

b34sexec data heading=('Box-Jenkins Data')

file='gas.dat'

/; file='/usr/local/hhsfiles/sasdata/gas.dat'

;

input n gasin gasout;

b34srun;

b34sexec options open('testsas.sas')

unit(29) disp=unknown$ b34srun$

b34sexec options clean(29) $ b34seend$

b34sexec pgmcall idata=29 icntrl=29$

sas $

* sas commands next ;

pgmcards$

proc reg; model gasout=gasin; run;

proc autoreg;

model gasout=gasin / method=ml nlag=1; run;

proc arima;

identify var=gasout(1); run;

proc arima;

identify var=gasout(1) noprint;

estimate p=4;

forecast lead=6;

run;

* version 8 ;

proc varmax ;

model gasin gasout;

cointeg rank=1;

run;

b34sreturn$

b34srun $

b34sexec options close(29)$ b34srun$

b34sexec options dodos('start /w /r sas testsas' )

dounix('sas testsas' )

$ b34srun$

b34sexec options npageout noheader

writeout(' ','output from sas',' ',' ')

writelog(' ','output from sas',' ',' ')

copyfout('testsas.lst')

copyflog('testsas.log')

dodos('erase testsas.sas','erase testsas.lst','erase testsas.log')

dounix('rm testsas.sas','rm testsas.lst','rm testsas.log')

$ b34srun$

b34sexec options header$ b34srun$

Example Applications

Solving Klein's Model. The below listed Example shows data loading and how to use SYSLIN.

/****************************************************************/
/* Example 1: Klein's Model I */
*------Klein's Model I------*
| By L.R. Klein, Economic Fluctuations in the United States, 1921-1941 |
| (1950), NY: John Wiley.A macro-economic model of the U.S. with|
| three behavioral equations, and several identities. See Theil, p.456.|
*------*;
data klein;
input year c p w i x wp g t k wsum;
date=mdy(1,1,year);
format date monyy.;
y=c+i+g-t;
yr=year-1931;
klag=lag(k);
plag=lag(p);
xlag=lag(x);
label year='Year'
date='Date'
c='Consumption'
p='Profits'
w='Private Wage Bill'
i='Investment'
k='Capital Stock'
y='National Income'
x='Private Production'
wsum='Total Wage Bill'
wp='Govt Wage Bill'
g='Govt Demand'
i='Taxes'
klag='Capital Stock Lagged'
plag='Profits Lagged'
xlag='Private Product Lagged'
yr='YEAR-1931';
datalines;
1920.12.7..44.9...182.8.
192141.912.425.5 -0.245.62.73.97.7182.628.2
192245.016.929.31.950.12.93.23.9184.532.2
192349.218.434.15.257.22.92.84.7189.737.0
192450.619.433.93.057.13.13.53.8192.737.0
192552.620.135.45.161.03.23.35.5197.838.6
192655.119.637.45.664.03.33.37.0203.440.7
192756.219.837.94.264.43.64.06.7207.641.5
192857.321.139.23.064.53.74.24.2210.642.9
192957.821.741.35.167.04.04.14.0215.745.3
193055.015.637.91.061.24.25.27.7216.742.1
193150.911.434.5 -3.453.44.85.97.5213.339.3
193245.67.029.0 -6.244.35.34.98.3207.134.3
193346.511.228.5 -5.145.15.63.75.4202.034.1
193448.712.330.6 -3.049.76.04.06.8199.036.6
193551.314.033.2 -1.354.46.14.47.2197.739.3
193657.717.636.82.162.77.42.98.3199.844.2
193758.717.341.02.065.06.74.36.7201.847.7
193857.515.338.2 -1.960.97.75.37.4199.945.9
193961.619.041.61.369.57.86.68.9201.249.4
194065.021.145.03.375.78.07.49.6204.553.0
194169.723.553.34.988.48.513.811.6209.461.8
;
proc syslin data=klein outest=b liml;
endogenous c p w i x wsum k y;
instruments klag plag xlag wp g t yr;
consume: model c = p plagwsum;
invest:model i = p plagklag;
labor:model w = x xlagyr;
run;
proc print data=b; run;
proc syslin data=klein 3sls reduced;
endogenous c p w i x wsum k y;
instruments klag plag xlag wp g t yr;
consume: modelc = p plag wsum;
invest:modeli = p plag klag;
labor:modelw = x xlag yr;
product: identity x = c + i + g;
income:identity y = c + i + g - t;
profit:identity p = y - w;
stock:identity k = klag + i;
wage:identity wsum = w + wp;
run;

Error Component Models can be estimated with the tscsreg procedure

/****************************************************************/
/*S A SS A M P L EL I B R A R Y*/
/**/
/*NAME: tscex01.sas*/
/*TITLE: TSCSREG: User's Guide Example 1, Version 8*/
/* PRODUCT: ETS*/
/*SYSTEM: ALL*/
/*KEYS:*/
/*PROCS: TSCSREG*/
/*DATA: Feige (1964)*/
/**/
/* SUPPORT:*/
/*REF: SAS/ETS User's GUIDE: PROC TSCSREG CHAPTER*/
/**/
/*Feige, E.L. (1964), The Demand for Liquid Assets:*/
/*A Temporal Cross-Section Analysis, Englewood*/
/*Cliffs:Prentice-Hall.*/
/*MISC:*/
/**/
/****************************************************************/
/* Example 1: Analyzing Demand for Liquid Assets */
data a;
input state $ year d t s y rd rt rs;
label d = 'Per Capita Demand Deposits'
t = 'Per Capita Time Deposits'
s = 'Per Capita S & L Association Shares'
y = 'Permanent Per Capita Personal Income'
rd = 'Service Charge on Demand Deposits'
rt = 'Interest on Time Deposits'
rs = 'Interest on S & L Association Shares';
datalines;
CA19496.27856.19244.49987.2056 -1.07000.10801.0664
CA19506.40196.21064.68217.2889 -1.01060.15011.0767
CA19516.50586.27294.85987.3827 -1.00240.40081.1291
CA19526.47856.27295.00397.4000 -0.99700.44921.1227
CA19536.41186.25385.17617.4200 -0.89160.46621.2110
CA19546.45206.29715.36137.4478 -0.69510.47561.1924
CA19556.49986.30815.54527.4838 -0.70120.49291.2387
CA19566.51626.28975.72367.5380 -0.62920.56361.2638
CA19576.46466.37335.85797.5822 -0.46200.97121.3686
CA19586.51916.45526.03317.6178 -0.40500.97121.3818
CA19596.57096.46616.20257.6797 -0.40950.97381.3980
DC19496.74995.48065.82307.3796 -1.3432 -0.39161.0307
DC19506.92075.54135.94547.4804 -1.3205 -0.41251.0567
DC19517.07755.61316.14207.6094 -1.3243 -0.39011.1006
DC19526.98105.54526.21667.5606 -1.3205 -0.31611.0902
DC19536.91175.55306.29717.5262 -1.2483 -0.12441.1102
DC19546.95085.72036.43947.5326 -1.17770.40551.1259
DC19556.97265.79616.58207.5658 -1.14570.40811.1559
DC19566.96795.79916.66707.5761 -1.13320.46881.1787
DC19577.02115.96876.80027.6425 -1.06130.80241.2143
DC19587.08676.07996.91977.6704 -1.02170.74191.2404
DC19597.06306.00147.02917.6811 -0.87230.85101.3156
FL19496.01134.83634.63476.9315 -1.0385 -0.09540.8390
FL19506.07074.82834.72746.9147 -1.0729 -0.04400.8446
FL19516.15064.89034.93456.9735 -1.09360.00200.8871
FL19526.15274.88285.11806.9735 -1.11470.05070.9466
FL19536.13994.92735.29837.0370 -1.03850.11150.9651
FL19546.14204.94165.50947.0361 -0.98350.23741.0547
FL19556.30085.08145.81117.1747 -0.97290.29191.0585
FL19566.34045.11205.94807.1997 -0.91880.39611.1092
FL19576.27485.36606.03557.2320 -0.80520.88381.2054
FL19586.27855.48066.10267.2506 -0.69720.89731.2099
FL19596.25775.45966.23447.2841 -0.64820.91191.2740
IL19496.73705.87494.75367.2896 -1.9449 -0.16020.9179
IL19506.75695.83484.83637.2917 -1.9241 -0.16610.8953
IL19516.78785.81414.96987.3492 -1.9173 -0.06610.8957
IL19526.81785.94025.16487.4073 -1.93790.05730.9431
IL19536.81235.98145.34237.4448 -1.89710.08710.9944
IL19546.83306.02595.53347.4816 -1.80790.12221.0109
IL19556.84486.02595.69047.5038 -1.76030.13191.0217
IL19566.85016.05685.85797.5575 -1.69830.30311.0757
IL19576.80136.09135.97137.5909 -1.59450.48741.1490
IL19586.82336.13996.09587.6014 -1.54180.55221.2244
IL19596.77316.16336.19247.6183 -1.46530.71981.2519
NY19497.22265.60214.20477.3079 -2.1893 -0.37540.7415
NY19507.24785.56454.26277.3232 -2.1286 -0.32300.7333
NY19517.25065.53344.44277.3563 -2.1286 -0.22940.7966
NY19527.25915.60584.62507.4140 -2.12030.04880.8899
NY19537.24065.69044.77077.4639 -2.00990.21590.9070
NY19547.25495.76214.90537.4967 -1.93100.29710.9322
NY19557.26615.74625.00397.5000 -1.92410.34070.9764
NY19567.25565.82605.12407.5580 -1.78380.56191.0203
NY19577.27455.99155.24177.6372 -1.66600.80241.0842
NY19587.28146.11375.32797.6592 -1.65030.85871.1227
NY19597.25636.11815.40727.6948 -1.59450.92471.1703
TX19496.35094.23413.58356.9027 -1.9038 -0.17551.0134
TX19506.45204.26273.73776.9584 -1.9173 -0.17911.0080
TX19516.52064.34383.89187.0510 -1.9105 -0.20831.0364
TX19526.50434.43084.06047.0699 -1.91730.06771.0578
TX19536.50134.59514.29057.1131 -1.83260.15701.1256
TX19546.56244.76224.52187.1585 -1.70370.28371.1291
TX19556.58204.84424.70957.1967 -1.65550.31331.1220
TX19566.56244.88284.82037.2138 -1.57020.43441.1210
TX19576.51475.06894.96987.2556 -1.38630.75191.2490
TX19586.57375.30335.10597.2841 -1.28010.80691.2276
TX19596.55545.35195.27817.3265 -1.19400.88991.3005
WA19496.03555.30334.49987.0440 -1.0272 -0.06510.7266
WA19506.21665.37534.69137.1884 -1.0189 -0.02740.8016
WA19516.26345.39364.85207.2675 -1.00790.03830.8616
WA19526.25195.43814.96987.3005 -0.96500.26620.9373
WA19536.21465.45965.15917.3337 -0.88190.29421.0466
WA19546.28605.50945.36137.3790 -0.73190.29861.0526
WA19556.30085.58355.50537.4079 -0.63680.57101.0671
WA19566.26345.59105.57227.4122 -0.53270.57611.1023
WA19576.20255.65955.65257.4448 -0.38420.83851.1793
WA19586.25585.73335.76217.4697 -0.33410.83381.1957
WA19596.24425.75575.84357.5005 -0.31470.91431.2548
;
proc print data=a(obs=5);
run;
proc sort data=a;
by state year;
run;
title 'Demand for Liquid Assets';
proc tscsreg data=a;
model d = y rd rt rs / fuller parks dasilva m=7;
model t = y rd rt rs / parks;
model s = y rd rt rs / parks;
id state year;
run;