Introduction to SAS ISYS 650. What Is SAS? SAS is a collection of modules that are used to process and analyze data. It began in the late ’60s and early.

Slides:



Advertisements
Similar presentations
Haas MFE SAS Workshop Lecture 3:
Advertisements

CC SQL Utilities.
How to Import an Excel File Using the SAS Import Wizard SAS 9 for Windows.
The SAS ® System Additional Information on Statistical Analysis Programming.
Statistical Methods Lynne Stokes Department of Statistical Science Lecture 7: Introduction to SAS Programming Language.
Slide C.1 SAS MathematicalMarketing Appendix C: SAS Software Uses of SAS  CRM  datamining  data warehousing  linear programming  forecasting  econometrics.
S ORTING WITH SAS L ONG, VERY LONG AND LARGE, VERY LARGE D ATA Aldi Kraja Division of Statistical Genomics SAS seminar series June 02, 2008.
Chapter 3: Editing and Debugging SAS Programs. Some useful tips of using Program Editor Add line number: In the Command Box, type num, enter. Save SAS.
Knowing Understanding the Basics Writing your own code part 2 SAS Lab.
Today: Run SAS programs on Saturn (UNIX tutorial) Runs SAS programs on the PC.
Ann Arbor ASA ‘Up and Running’ Series: SPSS Prepared by volunteers of the Ann Arbor Chapter of the American Statistical Association, in cooperation with.
Perancangan Pencatatan Transaksi Pertemuan 21 s.d 22 Matakuliah: F0712 / Lab Sistem Informasi Akuntansi Tahun: 2007.
SAS PROCs ISYS 650. PROC Statement Syntax PROC name options; Statements statement options; … RUN;
Categorical Data Analysis using SAS. 2 List the components of a SAS program. Open an existing SAS program and run it. Discuss the Chi Square Test of Independence.
SAS ® Regression Essentials. 2 List the components of a SAS program. Open an existing SAS program and run it. Objectives.
Introduction to SAS Math 3200 Jan Jimin Ding.
® IBM Software Group © 2006 IBM Corporation The Eclipse Data Perspective and Database Explorer This section describes how to use the Eclipse Data Perspective,
Understanding SAS Data Step Processing Alan C. Elliott stattutorials.com.
Exploring Office Grauer and Barber 1 Information From the Database: Reports and Queries(Wk4)
CHAPTER 9 DATABASE MANAGEMENT © Prepared By: Razif Razali.
Lecture 5 Sorting, Printing, and Summarizing Your Data.
SAS Workshop Lecture 1 Lecturer: Annie N. Simpson, MSc.
Introduction to SAS BIO 226 – Spring Outline Windows and common rules Getting the data –The PRINT and CONTENT Procedures Manipulating the data.
Analyzing Data For Effective Decision Making Chapter 3.
Introduction to SAS. What is SAS? SAS originally stood for “Statistical Analysis System”. SAS is a computer software system that provides all the tools.
Chapter 6 SAS ® OLAP Cube Studio. Section 6.1 SAS OLAP Cube Studio Architecture.
Quantify the Example Data First, code and quantify the data (assign column locations & variable names) Use the sample data to create a data set from the.
Math 3400 Computer Applications of Statistics Lecture 1 Introduction and SAS Overview.
PROC SQL Phil Vecchione. SQL Structured Query Language Developed by IBM in the early 1970’s From the 70’s to the late 80’s there were different types.
BMTRY 789 Introduction to SAS Programming Lecturer: Annie N. Simpson, MSc.
Using SAS® Information Map Studio
SAS Efficiency Techniques and Methods By Kelley Weston Sr. Statistical Programmer Quintiles.
What is a Database? A Database is…  an organized set of stored information usually on one topic  a collection of records  a way to organize information.
Knowing Understanding the Basics Writing your own code SAS Lab.
EPIB 698C Lecture 2 Notes Instructor: Raul Cruz 2/14/11 1.
Data Management Console Synonym Editor
Exploring Office Grauer and Barber 1 Committed to Shaping the Next Generation of IT Experts. Chapter 3 - Information From the Database: Reports.
ISU Basic SAS commands Laboratory No. 1 Computer Techniques for Biological Research Animal Science 500 Ken Stalder, Professor Department of Animal Science.
Introduction to Enterprise Guide Jennifer Schmidt Rhonda Ellis Cassandra Hall.
Introduction to Access ISYS 363. Creating a New Database MS Office button/New –Blank database –New database name and location.
1 Data Manipulation (with SQL) HRP223 – 2010 October 13, 2010 Copyright © Leland Stanford Junior University. All rights reserved. Warning: This.
Lesson 6 - Topics Reading SAS datasets Subsetting SAS datasets Merging SAS datasets.
Laboratory 1. Introduction to SAS u Statistical Analysis System u Package for –data entry –data manipulation –data storage –data analysis –reporting.
Chapter 5 Reading and Manipulating SAS ® Data Sets and Creating Detailed Reports Xiaogang Su Department of Statistics University of Central Florida.
Introduction to SAS Essentials Mastering SAS for Data Analytics Alan Elliott and Wayne Woodward SAS Essentials - Elliott & Woodward1.
Chapter 1: Overview of SAS System Basic Concepts of SAS System.
Introduction to Access BUS 782. Creating a New Database MS Office button/New –Blank database –New database name and location.
An Introduction Katherine Nicholas & Liqiong Fan.
Microsoft Access Introduction. What is a database? A DATABASE is a collection of related data.
Computing with SAS Software A SAS program consists of SAS statements. 1. The DATA step consists of SAS statements that define your data and create a SAS.
Introduction to Access ISYS 363. Access Objects Tables –Open –Design –New –Wizard Queries Forms Reports Pages.
FORMAT statements can be used to change the look of your output –if FORMAT is in the DATA step, then the formats are permanent and stored with the dataset.
HRP Copyright © Leland Stanford Junior University. All rights reserved. Warning: This presentation is protected by copyright law and.
Introduction to Access ISYS 363. Access Objects Tables –Open a table: Double click the table name –Home/View: Datasheet view Design view Queries Forms.
1 Data Manipulation (with SQL) HRP223 – 2009 October 12, 2009 Copyright © Leland Stanford Junior University. All rights reserved. Warning: This.
Chapter 6: Modifying and Combining Data Sets  The SET statement is a powerful statement in the DATA step DATA newdatasetname; SET olddatasetname;.. run;
1 EPIB 698C Lecture 1 Instructor: Raul Cruz-Cano
SAS Programming Training Instructor:Greg Grandits TA: Textbooks:The Little SAS Book, 5th Edition Applied Statistics and the SAS Programming Language, 5.
HRP Copyright © Leland Stanford Junior University. All rights reserved. Warning: This presentation is protected by copyright law and.
Based on Learning SAS by Example: A Programmer’s Guide Chapters 1 & 2
Online Programming| Online Training| Real Time Projects | Certifications |Online Classes| Corporate Training |Jobs| CONTACT US: STANSYS SOFTWARE SOLUTIONS.
Outline of Script Import Modules Setup Workspace Environment and Assign Data Path Variables Summary of Script Title and Author Info.
Chapter 2 Build Your First Project A Step-by-Step Approach 2 Exploring Microsoft Visual Basic 6.0 Copyright © 1999 Prentice-Hall, Inc. By Carlotta Eaton.
SAS ® 101 Based on Learning SAS by Example: A Programmer’s Guide Chapters 5 & 6 By Ravi Mandal.
Data Virtualization Tutorial: Introduction to SQL Script
SAS Programming Introduction to SAS.
Module 13: Creating Data Visualizations with Power View
Combining Data Sets in the DATA step.
Topic 11 Lesson 1 - Analyzing Data in Access
Introduction to SAS Lecturer: Chu Bin Lin.
Presentation transcript:

Introduction to SAS ISYS 650

What Is SAS? SAS is a collection of modules that are used to process and analyze data. It began in the late ’60s and early ’70s as a statistical package (Statistical Analysis System). SAS is also an extremely powerful, general- purpose programming language. In recent years, it has been enhanced to provide state-of-the-art data mining tools and programs for Web development and analysis.

Data-Driven Tasks The functionality of the SAS System is built around the four data-driven tasks common to virtually any application: 1. data access: – addresses the data required by the application 2. data management: – shapes data into a form required by the application 3. data analysis: – summarizes, reduces, or otherwise transforms raw data into meaningful and useful information 4. data presentation: – communicates information in ways that clearly demonstrate its significance

An Overview of SAS Data Processing DATA steps are used to create SAS data sets. PROC steps are used to process SAS data sets.

Explore the SAS workspace When you first start SAS, the five main SAS windows open: – the Explorer – Results – Program Editor or Editor – Log – Output windows. Menu: – Tools: New Library

Demo Creating a new library: – Tools/New Library: Name Folder Enable at start up import a table to the new library from MS Access database and create a SAS data set: – File/Import data Open a SAS dataset: a SAS data set (also called a table) is a file containing descriptor information and related data values. The file is organized as a table of observations (rows) and variables (columns) that SAS can process.

Components of SAS programs DATA steps typically create or modify SAS data sets. For example, you can use DATA steps to – put your data into a SAS data set – compute the values for new variables – check for and correct errors in your data – produce new SAS data sets by subsetting, merging, and updating existing data sets. PROC (procedure) steps typically analyze and process data in the form of a SAS data set, and they sometimes create SAS data sets that contain the results of the procedure.

A program accessing the SAS data set named “student” in Mydata library DATA myStudent; set Mydata.student; run; PROC print data=myStudent; run; Note: The DATA statement creates a temporary data set that references the “student” data set in the Mydata library. Temporary data sets are stored in the Work library.

SAS Data Access 1. Import Wizard: File/Import Data Demo: Access, Excel

Process SAS Data Set 1. Reference the library name: PROC print data=mydata.emp; run; 2. Reference the Windows name directly: PROC print data="c:\mydata\emp"; run; 3. Creating a temporary SAS data set from existing SAS data set: DATA myStudent; *USE Mydata.student; *USE "C:\Mydata\student"; *SET Mydata.student; SET "C:\Mydata\student"; run; PROC print data=myStudent; run; Note: To add line comment, use “*”. To add block comment, use /* …. */

Creating a Permanent SAS Data Set by Using Windows’ File Name or Library.FileName in Data Statement DATA "c:\MyData\myStudent"; *USE Mydata.student; *USE "C:\Mydata\student"; *SET Mydata.student; SET "C:\Mydata\student"; run; Note: This example creates a new permanent data set from the “student” data set in MyData library. DATA MyData.myStudent; SET "C:\Mydata\student"; run;

Creating a Data Set Using Input Statement DATA MyData.StGPA2; INPUT SID $ Sname $ GPA; DATALINES; S1 Peter 3.2 S2 Paul 2.8 S3 Mary 3.0 run; DATA StGPA; INPUT SID $ Sname $ GPA; DATALINES; S1 Peter 3.2 S2 Paul 2.8 S3 Mary 3.0 run; Temporary data set: Permanent data set:

SAS Data Access 2. Using ODBC with PROC SQL PROC SQL; CONNECT TO ODBC(DSN='MySalesDB2007'); CREATE TABLE temp_sas AS SELECT * FROM CONNECTION TO ODBC(SELECT * FROM Customer); Data Customer; set Work.temp_sas; run; PROC Print DATA=Customer; run; Note: The CREATE TABLE statement creates a SAS data set from the Customer table.

Create a SAS Data Set as the Result of a SQL Join Statement PROC SQL; CONNECT TO ODBC(DSN='MySalesDB2007'); CREATE TABLE temp_sas AS SELECT * FROM CONNECTION TO ODBC(SELECT Customer.CID, Cname, OID, Odate FROM Customer, Orders where Customer.cid=orders.cid); Data CustomerOrder; set Work.temp_sas; run; PROC Print DATA=CustomerOrder; run;

SAS Data Management Creating calculated field Use DROP and KEEP to select fields Create a subset of a data set Append two data sets Merge data set – Equivalent to SQL outer join

Creating Calculated Field Arithmetic operators: – +, -, *, /, ** Using SAS functions: – ABS, INT, SQRT, ROUND – Date functions: TODAY(): return current date INTCK(‘interval’,from, to) – The ‘interva’ can be: DAY, WEEK, MONTH, QTR, YEAR – Example: Age = intck('year',dob,today()); Year, Month, Qtr

Examples DATA GPAGroup; set work.Mystudent; IF GPA <2.0 then scholarship=1000; Else scholarship=3000; IF GPA <2.0 then GRPGrp='Poor'; Else GPAGrp='Good'; run; proc print data=GPAGroup; run; DATA AgeGroup; set Mydata.student2; Age = year(today())-year(DOB); run; proc print data=AgeGroup; run;

DROP/KEEP DATA Student; set work.Mystudent; DROP Gender DOB; run; proc print data=Student; run;

Subset a Data Set with IF DATA highIncome; set Mydata.Emp; IF Salary>60000; run; proc print data=highIncome; run;

Vertically Merging Two Data Sets (Append) DATA StDOB; set Mydata.Student; Name=Sname; KEEP Name DOB; run; DATA EmpDOB; set Mydata.Emp; DOB=Birthdate; KEEP Name DOB; run; DATA AllDOB; SET STDOB EmpDOB; Run; proc print data=ALLDOB; run;

Horizontally Merging Two Data Sets (1. Must be sorted by the same field; 2. this operation is equivalent to SQL Outer Join) PROC SQL; CONNECT TO ODBC(DSN='MySalesDB2007'); CREATE TABLE temp_sas AS SELECT * FROM CONNECTION TO ODBC(SELECT * FROM Customer); CREATE TABLE temp_sas2 AS SELECT * FROM CONNECTION TO ODBC(SELECT * FROM Orders); PROC SORT Data=Work.temp_sas; BY CID; PROC SORT Data=Work.temp_sas2; BY CID; Data CustomerOrders; MERGE temp_sas temp_sas2; BY CID; KEEP CID CNAME OID ODATE SALESPERSON; run; PROC Print DATA=CustomerOrders; run;

A few SAS PROCs PROC PRINT PROC SORT PROC MEANS PROC SQL