Business Econometrics Using SAS Tools (BEST) : Class II - Introducing SAS Code
Business Econometrics Using SAS Tools (BEST) : Class II - Introducing SAS Code
The CODE
We worked with EG till now
But, here is the Real Deal
Open EG File>New>Code
OPTIONS
PROC OPTIONS;
RUN;
Infile
* Read data from external file into
SAS data set;
DATA uspresidents;
INFILE 'c:\sasdata\President.dat';
INPUT President $ Party $ Number;
RUN;
Import
Syntax:
PROC IMPORT DATAFILE = filename OUT = dataset
DBMS = identifier REPLACE;
Type of File
Extension
DBMS
Identifier
Excel
dBase
JMP
Lotus
Paradox
SPSS
Stata
.xls
.dbf
.jmp
.wk4
.db
.sav
.dta
EXCEL/XLS
DBF
JMP
WK4
PARADOX
SAV
DTA
Import Examplecsv
*imports a csv file into sas;
PROC IMPORT DATAFILE
='c:\sasdata\stocks.csv' OUT =
stocks REPLACE;
RUN;
PROC PRINT DATA = stocks;
TITLE 'Some Stocks and EPS';
RUN;
Import .xls
Additional details (if you need)
Specify if you want to input only a certain
sheet from the Excel File
SHEET = sheet-name;
Import Examplexls
PROC IMPORT DATAFILE =
'c:\sasdata\stocks.xls' DBMS=EXCEL
OUT = stocks;
RUN;
PROC PRINT DATA = stocks;
TITLE 'SAS Data Set Read From Excel
File';
RUN;
DATAFILE=
"C:\sasdata\PaymentReg.csv"
DBMS=CSV REPLACE;
GETNAMES=YES;
DATAROW=2;
RUN;
Next step
Step 2 List the data
Do it in parts, if needed, to take a look
into the dataset
Summary Statistics
PROC MEANS DATA=WORK.payreg
FW=4
MEAN
STD
MIN
MAX
N;
RUN;
Correlations
PROC CORR DATA=WORK.PAYREG
PEARSON;
RUN;
Histogram
PROC UNIVARIATE
DATA=WORK.payreg NOPRINT;
VAR SR;
HISTOGRAM / CAXES=BLACK
CBARLINE=BLACK CFILL=BLACK
PFILL=SOLID WAXIS=1;
RUN;