Anda di halaman 1dari 17

SAS Session

g GE Capital - ACoE Overview

• What is SAS
— Statistical Analysis System / Software.

SAS
— Integrated system of software products.

• Data Entry, Retrieval, and


Management.
• Report Writing and Creating
Graphics.
• Statistical and Mathematical
Analysis.
• Business Forecasting•and
The SAS Language
Decision Support. • Procedures for
analysis and
• Operations Research and Project
reporting
Management.
• A Macro Facility
• Web Applications. • A Windowing
Environment

SAS Session 22-May-01 Version 1.0 2


g GE Capital - ACoE Overview

• Components of SAS
— 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 • Excel
• Explorer Window.
• Word
• Tools.
• DATA • SPSS
• PROC • ORACLE
• RUN / QUIT

Every SAS Statements Ends With a Semicolon ;

SAS Session 22-May-01 Version 1.0 3


g GE Capital - ACoE Data - Concept

• Data, Observation, and Variables

Variable / Column

Values
Observation / Rows

DATA / TABLE

Only 2 types of variables - Numeric and Character

SAS Session 22-May-01 Version 1.0 4


g GE Capital - ACoE Create, Check and Store Data

• Creating SAS Data Sets


…directly in the EDITOR - CARDS, DATALINES.
s External Files…reading .txt, .dat or other flat files.
Existing SAS data sets.
• .ssd01
• .sas7bdat
• .sd2
• SAS Data sets
• Use SET Statement
• .txt • USE of LIBNAME
• .dat
SAS
• .csv, etc • Manage
• Analyze • New SAS Data
• External Files • Create new data
• Access through INFILE Statement • Other Files
• Use of FILENAME.
• PERMANENT Data
PROC PRINT / PROC CONTENTS gives an idea...

SAS Session 22-May-01 Version 1.0 5


g GE Capital - ACoE Observations and Variables

• Subsetting

(drop = c) ;

‘KEEP’
also
(drop = b c) ; could
be used

• IF
• WHERE
• DELETE
• OBS / FIRSTOBS
• OUTPUT

For Most Efficient Result Use Both...

SAS Session 22-May-01 Version 1.0 6


g GE Capital - ACoE Variables

• Manipulating Variables
• Assign LABEL, FORMAT.
• Create New Variables from the Old Ones.
• NUM & CHAR Variables.
• Different Types of Functions.
• NUM to CHAR and CHAR to NUM.
• Sequential processing.
• FORMAT, INFORMAT.
• SAS Date Variables.
• Missing Values

• Informat is used for


reading data
• Format is for printing

SAS Session 22-May-01 Version 1.0 7


g GE Capital - ACoE Records

• Manipulate Records
ng the file physically…BY, NODUPKEY, DESCENDING.
the FIRST and LAST record in a group processing.
nd RETAIN.
late using +.
omize using RANUNI.
ing the records.
LAST.a

FIRST.a

Note: FIRST.a = LAST.a for unique records...

SAS Session 22-May-01 Version 1.0 8


g GE Capital - ACoE Multiple Data Sets

• Working With More Than One Data Set


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...

SAS Session 22-May-01 Version 1.0 9


g GE Capital - ACoE Multiple Data Sets

• APPEND, SET, MERGE

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...

SAS Session 22-May-01 Version 1.0 10


g GE Capital - ACoE Data

• Advanced Data Processing


_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
Dangerous “”.

SAS

ARRAY sl[4] sale11 sale21 sale31 sale41 ;


FILE
writes to
external file
sl(1) sl(2) sl(3) sl(4)

Usage of ARRAY simplifies the coding...

SAS Session 22-May-01 Version 1.0 11


g GE Capital - ACoE Simple Procedures

• Statistical 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...

SAS Session 22-May-01 Version 1.0 12


g GE Capital - ACoE SQL

• Structured Query Language


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...

SAS Session 22-May-01 Version 1.0 13


g GE Capital - ACoE Remote Session

• Working in the Remote Session


• Signon
• Rsubmit Remote
• Endrsubmit SAS
• Script File (RLINK)
• UPLOAD & DOWNLOAD

Local SAS

TCP / IP Socket

Confusion with local and remote data sets...

SAS Session 22-May-01 Version 1.0 14


g GE Capital - ACoE Macro

• What is Macro? Data set variable

&
• & and % and its values
• %let and %put
• %macro and %mend Macro variable
• Argument and its value.
• Open Code
• %global and %local
• CALL SYMPUT
• Invoking a macro
• ‘’ and “” in a macro
• MPRINT, SYMBOLGEN
• %include
DATA DSN_SUKIRAN ;
SET OLDDSN ;

%
WHERE UPCASE(NAME) = “SUKIRAN” ;
SAS RUN ;

(Macro Processor) OPTIONS MPRINT ;


PROC PRINT DATA = DSN_SUKIRAN ;
TITLE “Spending details for the person Sukiran.” ;
RUN ;

Macro variables are always CHARACTER variables...

SAS Session 22-May-01 Version 1.0 15


g GE Capital - ACoE SAS Does it!

• Think of Anything……SAS does it for YOU


voke X window command.
vanced use of FILENAME.
n VB Macro from SAS.
eate HTML / PDF / ActiveX / JAVA Applet using SAS.
nd EMAIL.
teract with EXCEL X
tomate, Digitize... Command

Digitization
DDE,
Run VB
D:\Baseline.xls
Macro SAS D:\States.pdf
FTP,
ODS

SAS is THE key...

SAS Session 22-May-01 Version 1.0 16


g GE Capital - ACoE

Thank YOU...

SAS Session 22-May-01 Version 1.0 17