Upload
sarathannapareddy
View
8.169
Download
0
Embed Size (px)
DESCRIPTION
SAS macros, SAS procs, DAtastep
Citation preview
SAS Session
22-May-01SAS Session 2
GE Capital - ACoEg
Version 1.0
Overview
• What is SAS
— Statistical Analysis System / Software.
— Integrated system of software products.
• Data Entry, Retrieval, and Management.• Report Writing and Creating Graphics.• Statistical and Mathematical Analysis.• Business Forecasting and Decision Support.• Operations Research and Project Management.• Web Applications.
SAS• The SAS Language• Procedures for analysis and reporting• A Macro Facility• A Windowing Environment
22-May-01SAS Session 3
GE Capital - ACoEg
Version 1.0
• Components of SAS
— Base SAS.
— STAT / GRAPH / OR / FSP / AF / IML / ASSIST / QC / CONNECT / INSIGHT / EIS / ETS / MDDB Server / ACC-PC File Formats.
Every SAS Statements Ends With a Semicolon ;
• Excel• Word• SPSS• ORACLE
• DATA• PROC• RUN / QUIT
• The LOG, Enhanced Editor, Output Window.• Help and Online Help• Explorer Window.• Tools.
Overview
• Invoke a SAS Session / Structure / Interaction
22-May-01SAS Session 4
GE Capital - ACoEg
Version 1.0
• Data, Observation, and Variables
Variable / Column
Observation / Rows
DATA / TABLE
Values
Only 2 types of variables - Numeric and Character
Data - Concept
22-May-01SAS Session 5
GE Capital - ACoEg
Version 1.0
• Creating SAS Data Sets
• Input…directly in the EDITOR - CARDS, DATALINES.• Access External Files…reading .txt, .dat or other flat files. • Read Existing SAS data sets.
SAS
• Manage• Analyze• Create new data
• .txt• .dat• .csv, etc
• .ssd01• .sas7bdat• .sd2
• External Files• Access through INFILE Statement• Use of FILENAME.
• SAS Data sets• Use SET Statement• USE of LIBNAME
• New SAS Data• Other Files
• PERMANENT Data
Create, Check and Store Data
PROC PRINT / PROC CONTENTS gives an idea...
22-May-01SAS Session 6
GE Capital - ACoEg
Version 1.0
Observations and Variables
• Subsetting
(drop = c) ;
(drop = b c) ;‘KEEP’
also could
be used
• IF• WHERE• DELETE• OBS / FIRSTOBS• OUTPUT
For Most Efficient Result Use Both...
22-May-01SAS Session 7
GE Capital - ACoEg
Version 1.0
• 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
Variables
• Informat is used for reading data• Format is for printing
22-May-01SAS Session 8
GE Capital - ACoEg
Version 1.0
Records
• Manipulate Records• Sorting the file physically…BY, NODUPKEY, DESCENDING.• Keep the FIRST and LAST record in a group processing.• LAG and RETAIN.• Cumulate using +.• Randomize using RANUNI.• RANKing the records.
FIRST.a
Note: FIRST.a = LAST.a for unique records...
LAST.a
22-May-01SAS Session 9
GE Capital - ACoEg
Version 1.0
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 KEYVariable
IF aa and bb
Duplicate records in both the files produce unexpected results...
22-May-01SAS Session 10
GE Capital - ACoEg
Version 1.0
• APPEND, SET, MERGE
DATA1 DATA2
DATA1DATA2
DATA2DATA1
DATA2
DATA1
• SET• BY processing possible
• MERGE• BY processing should be done
• APPEND • No BY variable • FORCE possible
Multiple Data Sets
Decide which one you need to use...
22-May-01SAS Session 11
GE Capital - ACoEg
Version 1.0
Data
• Advanced Data Processing• _NULL_ Data Step, PUT.• Know how a function works using _NULL_ Data. • IF, THEN, DO, END• ARRAY and DO Loops.• INFILE, FILE• Dangerous “”.
ARRAY sl[4] sale11 sale21 sale31 sale41 ;
sl(1) sl(2) sl(3) sl(4)
Usage of ARRAY simplifies the coding...
SAS
INFILEreads
external file
FILEwrites to
external file
22-May-01SAS Session 12
GE Capital - ACoEg
Version 1.0
Simple Procedures
PROC MEANS
Meansale = mean(sale11,sale21,sale31,sale41)
• Use of WHERE, FORMAT and TITLE.• PROC MEANS• Difference of PROC MEANS / Mean function• FREQ• UNIVARIATE• TABULATE• REG• LOGISTIC• PROC ...
• Statistical Procedures
Thousands of PROCedures...
22-May-01SAS Session 13
GE Capital - ACoEg
Version 1.0
SQL
• Structured Query Language
• SELECT, FROM and GROUP BY• CREATE TABLE • COUNT, SUM, MIN, MAX at an aggregate level• WHERE and ORDER BY
Data Set in SAS is TABLE in SQL...
PROC SQL ; SELECT SUM(Amt) AS Spend
FROM MyTableWHERE Month = ‘Dec’ ;
QUIT ;
22-May-01SAS Session 14
GE Capital - ACoEg
Version 1.0
Remote Session
• Working in the Remote Session• Signon• Rsubmit• Endrsubmit• Script File (RLINK)• UPLOAD & DOWNLOAD
TCP / IP Socket
Local SAS
Remote SAS
Confusion with local and remote data sets...
22-May-01SAS Session 15
GE Capital - ACoEg
Version 1.0
&
%
Macro
• What is Macro?• & and %• %let and %put• %macro and %mend• Argument• Open Code• %global and %local• CALL SYMPUT• Invoking a macro• ‘’ and “” in a macro• MPRINT, SYMBOLGEN• %include
Data set variable and its values
Macro variable and its value.
DATA DSN_SUKIRAN ;SET OLDDSN ;WHERE UPCASE(NAME) = “SUKIRAN” ;RUN ;
OPTIONS MPRINT ;PROC PRINT DATA = DSN_SUKIRAN ;TITLE “Spending details for the person Sukiran.” ;RUN ;
SAS(Macro Processor)
Macro variables are always CHARACTER variables...
22-May-01SAS Session 16
GE Capital - ACoEg
Version 1.0
Digitization
SAS Does it!
• Think of Anything……SAS does it for YOU• Invoke X window command.• Advanced use of FILENAME.• Run VB Macro from SAS.• Create HTML / PDF / ActiveX / JAVA Applet using SAS.• Send EMAIL.• Interact with EXCEL• Automate, Digitize...
D:\Baseline.xls SASSASDDE,Run VB Macro
X Command
D:\States.pdfFTP,ODS
SAS is THE key...
22-May-01SAS Session 17
GE Capital - ACoEg
Version 1.0
Thank YOU...