0% found this document useful (0 votes)
42 views15 pages

Business Econometrics Using SAS Tools (BEST) : Class II - Introducing SAS Code

This document provides an introduction to using SAS code to import data from external files, perform basic data exploration and analysis. It demonstrates how to import data from Excel, CSV and other file types into SAS data sets using PROC IMPORT and how to view and modify import options. Basic SAS procedures like PROC PRINT, PROC MEANS, PROC CORR and PROC UNIVARIATE are shown to list, summarize and explore the relationships in the imported data.

Uploaded by

Rohit Raj
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
42 views15 pages

Business Econometrics Using SAS Tools (BEST) : Class II - Introducing SAS Code

This document provides an introduction to using SAS code to import data from external files, perform basic data exploration and analysis. It demonstrates how to import data from Excel, CSV and other file types into SAS data sets using PROC IMPORT and how to view and modify import options. Basic SAS procedures like PROC PRINT, PROC MEANS, PROC CORR and PROC UNIVARIATE are shown to list, summarize and explore the relationships in the imported data.

Uploaded by

Rohit Raj
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 15

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;

Now open the Log


It allows you to make some changes
to the SAS System or Output for the
entire program
In EG Tool>Options
Ex: Results Format

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;

If you want to choose the range of data from


a given sheet. Here UL is the Upper Left cell
and LR is the Lower Right cell
RANGE = sheet-name$UL:LR;

Default in SAS is that the first lines in Excel


imports are variable names. To change that
GETNAMES = NO;

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;

Work with Project Data


Client wants to create a model to
predict TP
Need to understand if there are any
relationships between the dependent
and the independent variables

Work with live project data


PROC IMPORT OUT= WORK.payreg

DATAFILE=
"C:\sasdata\PaymentReg.csv"

DBMS=CSV REPLACE;

GETNAMES=YES;

DATAROW=2;
RUN;

Where does one begin?


Step 1 Check the data
What is the problem?
In this case, 2 of the variables have been
imported as characters

How to fix it?


Move the read only check mark in Data
Go back to the data, select the columns >
Properties

Next step
Step 2 List the data
Do it in parts, if needed, to take a look
into the dataset

PROC PRINT DATA=WORK.payreg;


VAR SR CS AR SC PIP; *drop this line
if you want to list the whole data;
RUN;

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;

You might also like