Вы находитесь на странице: 1из 20

Overview of SAS System

What is SAS
Overview

— Statistical Analysis System / Software.

— Integrated system of software products.

Data Entry, Retrieval, and Management.


SAS

• Report Writing and Creating Graphics.
• Statistical and Mathematical Analysis.
• Business Forecasting and Decision Support.
• Operations Research and Project Management.
• Web Applications.
• The SAS Language
• Procedures for analysis and
reporting
• A Macro Facility
• A Windowing Environment
Components of SAS
Overview
— Base SAS.
— STAT / GRAPH / OR / FSP / AF / IML / ASSIST / QC /
CONNECT / INSIGHT / EIS / ETS / MDDB Server / ACC-PC
— File Formats.

• Invoke a SAS Session / Structure / Interaction


• The LOG, Enhanced Editor, Output Window.
• Help and Online Help
• Explorer Window. • Excel
• Tools. • Word
•DATA • SPSS
• PROC • ORACLE
• RUN / QUIT

Every SAS Statement Ends With a Semicolon ;


The Base SAS Software

The Base SAS Software consists of

 SAS Language
 SAS Procedures
 Macro Facility
 Data Step Debugger
 Output Delivery System (ODS)
Components of a SAS Program

‘ Raw Data

Data Step SAS Data Proc Step Report


Set

SAS Data
Set
Components of a SAS Program

 Data Step
This step creates a SAS data set by processing input data. The input data
can be in the form of raw data, another SAS data set or assignment
statements.

 Proc Step
This step will execute a SAS procedure, with a SAS data set as input. It will
help us to analyze the data in a data set, produce reports and other results.
Data, Observation, and Variables
Data - Concept

Variable / Column

Values
Observation / Rows

DATA / TABLE
Only 2 types of variables - Numeric and Character
SAS Variables

There are two types of variables


Character
 Contains any value, letters, numbers, special characters and blanks
 Maximum length of 32,767 bytes
 One byte stores one character
Numeric
 Stored as floating point numbers of 8 bytes by default
 16 or 17 significant digits can be stored in these 8 bytes
 Length not restricted to 8 bytes
SAS Date Values

SAS stores date values as numeric values.


A SAS date value is stored as the number of days between
January 1, 1960 and a specific date.

01JAN1959 01JAN1960 01JAN1961

store
- 365 0 366
display

01/01/1959 01/01/1960 01/01/196


1
Missing Data Values

A value must exist for every variable for each observation.


Missing values are valid values.

• A character missing value is displayed as a blank ( )


• A numeric missing value is displayed as a period (.)
Compilation and Execution

The SAS data step is processed in two phases


 compilation
 execution
Compile Program

Initialize variables
to missing

YES
Execute input statement End of file

Execute other statements Next Step


NO

Output to SAS data set


Compiling the Data Step

At compile time SAS creates


 an input buffer to hold the current flat file record

a program data vector (PDV) to hold the current observation

Lastname Firstname Open date Credit Limit Card Type


$12. $12. mmddyy8. 4. $10.
the descriptor portion of the output data set

Lastname Firstname Open date Credit Card Type


Limit
$12. $12. mmddyy8. $10.
4.
Executing the Data Step

• The execution starts with the data statement. Every time this statement executes,
the automatic variable _n_ is incremented by 1.
• The variables in PDV are set to missing.
• The record from the flat file is read into the input buffer.
• Other statements in the step get executed for the current record.
• At the end of the step, the observation is written to the output data set, the
pointer returns to the top of the data step and the variables in the PDV are reset
to missing.
• The data step terminates when SAS encounters the end of the flat file
Advanced Data Processing Data

• _NULL_ Data Step, PUT. INFILE


• Know how a function works using _NULL_ Data. reads
• IF, THEN, DO, END external file
• ARRAY and DO Loops.
• INFILE, FILE

SAS

ARRAY sl[4] sale11 sale21 sale31 sale41 ;


FILE
writes to
sl(1) sl(2) sl(3) sl(4) external file
Usage of ARRAY simplifies the coding...
Creating SAS Data Set

1----------12----------24--------32—36----------46
parthiban sudhan 10/29/014000mastercard
sood shalabh 10/19/012000visa
vatsal bhakta 12/11/005000visa
kumar praveen 12/21/003000mastercard

Data Step

data acct_arr;
infile ‘flat file name’;
input @1 lastname $12. @13 firstname $12. @25 open_date mmddyy8.
@33 credit_lmt 4. @37 card_type $10.;
run;
SAS Data Set

Lastname Firstname Open_Date Credit_Limit Card_Type


Parthiban Sudhan 15277 4000 mastercard
Sood Shalabh 15267 2000 visa
Vatsal Bhakta 14955 5000 visa
Kumar Praveen 14965 3000 mastercard
APPEND, SET, MERGE
Multiple Data Sets

DATA1 DATA2

DATA1
DATA1 DATA1
DATA2
DATA2
DATA2

• SET • MERGE • APPEND


• BY processing • BY processing • No BY variable
possible should be done • FORCE possible

Decide which one you need to use...


Working With More Than One Data Set
Multiple Data Sets
• Sorting and Indexing…BY variable.
• Merging…IN, IF aa / bb / aa and bb.
• Appending (Be Careful about the BASE data).
• SET 2 Data Sets.
• Smart SET-ing using BY.

Merging KEY
Variable

IF aa and bb

Duplicate records in both the files produce unexpected results...


Statistical Procedures
Simple Procedures

• Use of WHERE, FORMAT and TITLE.


• PROC MEANS
• Difference of PROC MEANS / Mean function
• FREQ
Meansale =
• UNIVARIATE
mean(sale11,sale21,sale31,sale41)
• TABULATE
• REG
• LOGISTIC
• PROC ...

PROC
MEANS

Thousands of PROCedures...
Structured Query Language
SQL

• SELECT, FROM and GROUP BY


• CREATE TABLE
• COUNT, SUM, MIN, MAX at an aggregate level
• WHERE and ORDER BY

PROC SQL ;
SELECT SUM(Amt) AS Spend
FROM MyTable
WHERE Month = ‘Dec’ ;
QUIT ;

Data Set in SAS is TABLE in SQL...


Thank You...

Вам также может понравиться