1 SAS SAS is a statistics software package developed by SAS Institute Inc. in U.S.A. SAS products include SAS/STAT, SAS/IML, SAS/OR,...... etc. The most.

Slides:



Advertisements
Similar presentations
Summary Statistics/Simple Graphs in SAS/EXCEL/JMP.
Advertisements

Database Basics. What is Access? Database management system Computer-based equivalent of a manual database Makes it easy to organize and update information.
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.
Chapter 17 Read Raw Data in Fixed Format using Formatted Input Objectives Distinguish between standard and nonstandard numeric data Read standard fixed-field.
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.
Statistics in Science  Introducing SAS ® software Acknowlegements to David Williams Caroline Brophy.
SAS Programming: Working With Variables. Data Step Manipulations New variables should be created during a Data step Existing variables should be manipulated.
Today: Run SAS programs on Saturn (UNIX tutorial) Runs SAS programs on the PC.
Biostatistical Methods II PubH 6415 Spring PubH 6415 – Biostatistics I Instructor: Susan Telke (office hours: lecture.
The Information Delivery Process Data In Information Out ManageOrganizeExploit.
SPSS Statistical Package for the Social Sciences is a statistical analysis and data management software package. SPSS can take data from almost any type.
Introduction to SPSS Short Courses Last created (Feb, 2008) Kentaka Aruga.
Introduction to SAS Essentials Mastering SAS for Data Analytics Alan Elliott and Wayne Woodward SAS Essentials - Elliott & Woodward1.
Into to SAS ®. 2 List the components of a SAS program. Open an existing SAS program and run it. Objectives.
Creating SAS® Data Sets
Welcome to SAS…Session..!. What is SAS..! A Complete programming language with report formatting with statistical and mathematical capabilities.
SAS Workshop Lecture 1 Lecturer: Annie N. Simpson, MSc.
Chapter 9 Producing Descriptive Statistics PROC MEANS; Summarize descriptive statistics for continuous numeric variables. PROC FREQ; Summarize frequency.
Introduction to SAS Essentials Mastering SAS for Data Analytics Alan Elliott and Wayne Woodward SAS ESSENTIALS -- Elliott & Woodward1.
PROC REPORT organizes the output in many ways, from the simple to highly complex… PROC REPORT NOWINDOWS HEADLINE HEADSKIP; COLUMN variable-list; DEFINE.
Introduction to SAS BIO 226 – Spring Outline Windows and common rules Getting the data –The PRINT and CONTENT Procedures Manipulating the data.
1 Experimental Statistics - week 4 Chapter 8: 1-factor ANOVA models Using SAS.
Learning the TSP2: a guide for students at the 国際総合学類筑波大学 RUNNING REGRESSIONS FROM A SPREADSHEET FILE If you are using a network browser to view this program,
Using SPSS for Windows Part II Jie Chen Ph.D. Phone: /6/20151.
Introduction to SAS. What is SAS? SAS originally stood for “Statistical Analysis System”. SAS is a computer software system that provides all the tools.
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.
Lesson 2.  To help ensure accurate data, rules that check entries against specified values can be applied to a field. A validation rule is applied to.
SAS 介绍和举例 Presented by 经济实验教学中心 商务数据挖掘中心. Raw Data Read in Data Process Data (Create new variables) Output Data (Create SAS Dataset) Analyze Data Using.
SAS Efficiency Techniques and Methods By Kelley Weston Sr. Statistical Programmer Quintiles.
EPIB 698C Lecture 2 Notes Instructor: Raul Cruz 2/14/11 1.
Chapter 17 Creating a Database.
Lesson 2 Topic - Reading in data Chapter 2 (Little SAS Book)
Chapter 1 Creating a Worksheet and a Chart
ISU Basic SAS commands Laboratory No. 1 Computer Techniques for Biological Research Animal Science 500 Ken Stalder, Professor Department of Animal Science.
Summer SAS Workshop Lecture 2. Summer Summer SAS Workshop Lecture 2 I’ve got Data…how do I get started? Libname Review How do you do arithmetic.
1 Filling in the blanks with PROC FREQ Bill Klein Ryerson University.
Introduction to SPSS. Object of the class About the windows in SPSS The basics of managing data files The basic analysis in SPSS.
A lesson approach © 2011 The McGraw-Hill Companies, Inc. All rights reserved. a lesson approach Microsoft® Excel 2010 © 2011 The McGraw-Hill Companies,
A Simple Guide to Using SPSS ( Statistical Package for the Social Sciences) for Windows.
Database Applications – Microsoft Access Lesson 4 Working with Queries 36 Slides in Presentation.
1 EPIB 698E Lecture 1 Notes Instructor: Raul Cruz 7/9/13.
Dr. Engr. Sami ur Rahman Research Methods in Computer Science Lecture: Data Analysis (Introduction to SPSS)
How to start using SAS Tina Tian. The topics An overview of the SAS system Reading raw data/ create SAS data set Combining SAS data sets & Match merging.
Laboratory 1. Introduction to SAS u Statistical Analysis System u Package for –data entry –data manipulation –data storage –data analysis –reporting.
SAS Basics. Windows Program Editor Write/edit all your statements here. Log Watch this for any errors in program as it runs. Output Will automatically.
1 EPIB 698C Lecture 4 Raul Cruz-Cano Summer 2012.
Chapter 1: Overview of SAS System Basic Concepts of SAS System.
SAS Basics. Windows Program Editor Write/edit all your statement here.
Microsoft® Excel Create an Excel table. 1 Work with the Table Tools Design tab. 2 Sort and filter records in a table. 3 Identify structured references.
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.
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.
Lesson 2 Topic - Reading in data Programs 1 and 2 in course notes –Chapter 2 (Little SAS Book)
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.
Based on Learning SAS by Example: A Programmer’s Guide Chapters 1 & 2
The Urban Institute - SAS Training6/9/20161 SAS Training This SAS Training Course was designed to introduce users at The Urban Institute to SAS programming.
IENG-385 Statistical Methods for Engineers SPSS (Statistical package for social science) LAB # 1 (An Introduction to SPSS)
SAS ® 101 Based on Learning SAS by Example: A Programmer’s Guide Chapters 5 & 6 By Ravi Mandal.
SAS ® 101 Based on Learning SAS by Example: A Programmer’s Guide Chapters 3 & 4 By Tasha Chapman, Oregon Health Authority.
Applied Business Forecasting and Regression Analysis
Introduction to SPSS.
By Dr. Madhukar H. Dalvi Nagindas Khandwala college
Instructor: Raul Cruz-Cano 7/9/2012
Chapter 2: Getting Data into SAS
Instructor: Raul Cruz-Cano
Tamara Arenovich Tony Panzarella
Instructor: Raul Cruz 9/4/13
Presentation transcript:

1 SAS SAS is a statistics software package developed by SAS Institute Inc. in U.S.A. SAS products include SAS/STAT, SAS/IML, SAS/OR, etc. The most common one is SAS/BASE which provides tools for:  information storage and retrieval  data modification and programming  report writing  statistical analysis  handling

2 Structure A SAS program basically contains two parts, the DATA and the PROC. DATA is the part which describes the data to be interpreted and the PROC is the part which tells SAS how we want the data to be processed and analysed.

3 SAS Statement Every SAS statement ends with a semicolon. More than one SAS statement can be put on a line. The following statements: DATA NEW ; INPUT X Y Z ; CARDS ; could also be written as: DATA NEW; INPUT X Y Z; CARDS;

4 How to Get Data into SAS Program There are two ways to put data into SAS program. The first method is to include the data inside the SAS program and the second method is to read data externally. In order to get the data from a file on hard disk or diskette into a SAS data set, we need the following statements:  DATA  INFILE  INPUT  RUN

5 data income; infile 'c:\income.dat'; input name$ sex$ salary; run; data income; input name$ sex$ salary; cards; George M2300 AmyF2500 SteveM2200 TomM4400 ; run;

6 Input Statement The following steps show you how to write Input Statement: 1)Begin with the word INPUT. 2)Choose the names of variables of each record. 3)If the variable is a character, put a dollar sign after it. 4)Write the number of the column where the values of the variables begin and end.

7 inputname$ 1-8 sex$ 9-9 salary; input name$ sex$ salary;

8 We may also discard certain observations by using the DELETE statement: data income; infile 'c:\income.dat'; input name$ 1-8 sex$ 9-9 salary; if sex = 'm’ then delete; run; Only females are selected.

9 Environment After invoking the SAS, there are three major window areas for you to work in, they are:  PROGRAM EDITOR- where you enter the SAS statements to be executed.  OUTPUT - where results output by SAS procedures are displayed.  LOG - displays messages from the SAS system as well as your SAS statements as they are executed

10

11

12

13

14

15

16

17

18 Program Sample 1 When we enter the following program into the PROGRAM EDITOR area and click the execution button (the button with a running person figure) the output will be shown in the OUTPUT AREA. data income; input n$ sex$ salary age; cards; john m mary f jack m helen f george m anna f ; proc print data = income; sum salary ; run;

19 The following will be shown in the OUTPUT AREA after the above program is executed. The SAS System 11:29 Friday, November 5, OBS N SEX SALARY AGE 1 john m mary f jack m helen f george m tony m vincent m anna f ====== When we click on the Printer Button the content in the OUTPUT AREA will be printed to the network printer.

20 Program Sample2 When we execute the following program a different output will be shown. Since we have the 'nodate' option, the date is not printed. The report title is printed according to what we have put down for title1 and title2. You may have several titles. They have to be named as title1, title2, title3 and so on. options nodate; title1 'XYZ Company'; title2 'Salary Report'; data income; input n$ sex$ salary age; cards; john m mary f helen f jack m tony m anna f willie m ; proc print data = income; var n sex; run; proc freq data = income; table sex * salary; run;

21 XYZ Company Salary Report OBS N SEX 1 john m 2 mary f 3 helen f 4 jack m 5 tony m 6 anna f 7 willie m XYZ Company Salary Report TABLE OF SEX BY SALARY SEX SALARY Frequency| Percent | Row Pct | Col Pct | 3000| 4500| Total f | 3 | 0 | 3 | | 0.00 | | | 0.00 | | | 0.00 | m | 1 | 3 | 4 | | | | | | | | | Total | 4 | 3 | options nodate; title1 'XYZ Company'; title2 'Salary Report'; data income; input n$ sex$ salary age; cards; john m mary f helen f jack m tony m anna f willie m ; proc print data = income; var n sex; run; proc freq data = income; table sex * salary; run;

22 Program Sample 3 The following program shows only the female employee data. You may notice that we have put a selection statement in our SAS program. When the value of sex is 'm' the male employee record will be removed. options nodate; title1 'XYZ Company'; title2 'Salary Report'; data income; input n$ sex$ salary age; if sex = 'm' then delete; cards; john m mary f helen f jack m tony m anna f willie m ; proc print data = income; var n sex salary age; run ;

23 XYZ Company Salary Report OBS N SEX SALARY AGE 1 mary f helen f anna f options nodate; title1 'XYZ Company'; title2 'Salary Report'; data income; input n$ sex$ salary age; if sex = 'm' then delete; cards; john m mary f helen f jack m tony m anna f willie m ; proc print data = income; var n sex salary age; run ;

24 Program Sample 4 The following SAS program will process an external data file. The external data file is a simple text file. The content of the data file and their corresponding column locations are listed below: Student Name-column 1 to column 10 Course-column 11 to column 14 Age-column 18 to column 19 *column 15 to column 17 ignored Albert Comp 17 May Acct 16 David Math 17 Helen Comp 16 George Acct 16 Peter Phys 17 Betty Math 16 Cindy Eng 16 Richard Acct 17 Oliver Math 16

25 data student; infile 'a:\student.dat'; input studnam $ 1-10 course $ age 18-19; run; proc print data = student; run; Albert Comp 17 May Acct 16 David Math 17 Helen Comp 16 George Acct 16 Peter Phys 17 Betty Math 16 Cindy Eng 16 Richard Acct 17 Oliver Math 16

Albert Comp 17 May Acct 16 David Math 17 Helen Comp 16 George Acct 16 Peter Phys 17 Betty Math 16 Cindy Eng 16 Richard Acct 17 Oliver Math 16

27 Read Data From Dbase III File We do not have to inform our SAS system about the variable names. Our SAS program will use the field names from our data base file as the variable names. This program reads a DbaseIII file 'EMPLOYEE Program Sample 5 The following program shows you how to read a Dbase III data file. The structure of our data file EMPLOYEE.DBF is as follows: Field Name Type Width Dec NAME Character 8 SEX Character 1 SALARY Numeric 5

28 FILENAME DBFILE 'A:\EMPLOYEE.DBF'; PROC DBF DB3 = DBFILE OUT = A; RUN; PROC PRINT DATA = A; RUN; PROC SORT DATA = A OUT = B; BY NAME; RUN; PROC PRINT DATA = B; VAR NAME SEX; RUN; The SAS System 17:09 Friday, November 5, 1999 OBS NAME SEX SALARY 1 ALBERT M MARY F ANNA F STEVEN M GEORGE M ROSE F HELEN F CINDY F TONY M TOM M PETER M MONA F JAMES M 2190 The SAS System 17:09 Friday, November 5, 1999 OBS NAME SEX 1 ALBERT M 2 ANNA F 3 CINDY F 4 GEORGE M 5 HELEN F 6 JAMES M 7 MARY F 8 MONA F 9 PETER M 10 ROSE F 11 STEVEN M 12 TOM M 13 TONY M

29 Keyword Definition RUN-Tells the SAS system to execute the previous SAS statements. CARDS-Tells the SAS system that the data lines come next. You should enter one observation per data line. You must leave at least one blank between values. DATA-Most collections of data are made up of many observations, each contains several variables. PROC-Procedure RECALL-Put the SAS statements back to Program Editor. BYE-Leave SAS system ENDSAS-Leave SAS system FILE-Export data from active working window area e.g.File 'a:\abc.txt' INCLUDE-Import external data into active working window area e.g.include 'a:\sa.SAS' CLEAR-Erase working window area ZOOM-Enlarge working window area OPTIONS-Specify system options for the SAS sessions. e.g.OPTIONS NODATE LS=132

30 (a)Print Data Set (all) PROC PRINT DATA = INCOME; RUN; (b)Print Data Set (only the specified variables) PROC PRINT DATA = INCOME; VAR NAME SEX; RUN; (c)Print Data Set (with titles) PROC PRINT DATA = INCOME; title1 'Employee Report'; title2 'XYZ Company'; RUN; (d)Sort Data Set (by order of specified sort key) PROC SORT DATA = INCOME OUT=SRTEMP; BY NAME; RUN;

31 (e)PROC FREQ (Frequency Count) PRO FREQ DATA = INCOME; TABLE NAME * SEX; RUN; (f)PROC MEANS (Simple Statistics) PROC MEANS DATA = INCOME; RUN; (g)PROC GCHART (Simple Graphic Chart) PROC GCHART DATA = INCOME; VBAR SALARY; RUN; (h)PROC GCHART PROC GCHART DATA = INCOME; PIE SALARY; RUN;

32 That’s all