Statistical Methods Lynne Stokes Department of Statistical Science Lecture 7: Introduction to SAS Programming Language.

Slides:



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

Basics of Biostatistics for Health Research Session 2 – February 14 th, 2013 Dr. Scott Patten, Professor of Epidemiology Department of Community Health.
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.
Introduction to SAS Programming Christina L. Ughrin Statistical Software Consulting Some notes pulled from SAS Programming I: Essentials Training.
Statistics in Science  Introducing SAS ® software Acknowlegements to David Williams Caroline Brophy.
Today: Run SAS programs on Saturn (UNIX tutorial) Runs SAS programs on the PC.
SAS BASICS Technology Short Courses: Fall 2009 Kentaka Aruga.
Descriptive Statistics In SAS Exploring Your Data.
A Simple Guide to Using SPSS© for Windows
Basic And Advanced SAS Programming
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.
Understanding SAS Data Step Processing Alan C. Elliott stattutorials.com.
Welcome to SAS…Session..!. What is SAS..! A Complete programming language with report formatting with statistical and mathematical capabilities.
SAS Lecture 5 – Some regression procedures Aidan McDermott, April 25, 2005.
How to Analyze Data? Aravinda Guntupalli. SPSS windows process Data window Variable view window Output window Chart editor window.
Introduction to SAS Essentials Mastering SAS for Data Analytics
Tutor: Prof. A. Taleb-Bendiab Contact: Telephone: +44 (0) CMPDLLM002 Research Methods Lecture 9: Quantitative.
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.
1 Experimental Statistics - week 4 Chapter 8: 1-factor ANOVA models Using SAS.
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.
1 Experimental Statistics - week 2 Review: 2-sample t-tests paired t-tests Thursday: Meet in 15 Clements!! Bring Cody and Smith book.
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.
SAS 介绍和举例 Presented by 经济实验教学中心 商务数据挖掘中心. Raw Data Read in Data Process Data (Create new variables) Output Data (Create SAS Dataset) Analyze Data Using.
SAS lecture - week 31 Some Basics of CQUEST The operating system in the ESC lab (1046) is Linux. The operating system in RW labs (107/109 and 211) is Windows.
Chapter 1: Introduction to SAS  SAS programs: A sequence of statements in a particular order  Rules for SAS statements: –Every SAS statement ends in.
Lesson 2 Topic - Reading in data Chapter 2 (Little SAS Book)
ISU Basic SAS commands Laboratory No. 1 Computer Techniques for Biological Research Animal Science 500 Ken Stalder, Professor Department of Animal Science.
Introduction to SPSS. Object of the class About the windows in SPSS The basics of managing data files The basic analysis in SPSS.
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.
Chapter 1 – Matlab Overview EGR1302. Desktop Command window Current Directory window Command History window Tabs to toggle between Current Directory &
Chapter 22: Using Best Practices 1 STAT 541 ©Spring 2012 Imelda Go, John Grego, Jennifer Lasecki and the University of South Carolina.
Chapter 5 Reading and Manipulating SAS ® Data Sets and Creating Detailed Reports Xiaogang Su Department of Statistics University of Central Florida.
Lecture 3 Topic - Descriptive Procedures Programs 3-4 LSB 4:1-4.4; 4:9:4:11; 8:1-8:5; 5:1-5.2.
11/25/2015Slide 1 Scripts are short programs that repeat sequences of SPSS commands. SPSS includes a computer language called Sax Basic for the creation.
Introduction to SAS Essentials Mastering SAS for Data Analytics Alan Elliott and Wayne Woodward SAS Essentials - Elliott & Woodward1.
1.Introduction to SPSS By: MHM. Nafas At HARDY ATI For HNDT Agriculture.
Chapter 1: Overview of SAS System Basic Concepts of SAS System.
Social Science Research Design and Statistics, 2/e Alfred P. Rovai, Jason D. Baker, and Michael K. Ponton Between Subjects Analysis of Variance PowerPoint.
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.
1 Experimental Statistics - week 13 Multiple Regression Miscellaneous Topics.
1 PEER Session 02/04/15. 2  Multiple good data management software options exist – quantitative (e.g., SPSS), qualitative (e.g, atlas.ti), mixed (e.g.,
1 Introduction to SAS Available at
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.
Introduction to SPSS Review of Concepts (stats and scales) Data entry (the workspace and labels) – By hand – Import Excel Running an analysis-
SAS ® 101 Based on Learning SAS by Example: A Programmer’s Guide Chapters 3 & 4 By Tasha Chapman, Oregon Health Authority.
Android Online Training AcuteSoft: India: , Land Line: +91 (0) USA: , UK : +44.
Introduction to SPSS.
By Dr. Madhukar H. Dalvi Nagindas Khandwala college
Jonathan W. Duggins; James Blum NC State University; UNC Wilmington
DEPARTMENT OF COMPUTER SCIENCE
MATLAB DENC 2533 ECADD LAB 9.
Chapter 1: Introduction to SAS
Instructor: Raul Cruz-Cano
Tamara Arenovich Tony Panzarella
Producing Descriptive Statistics
Instructor: Raul Cruz 9/4/13
Presentation transcript:

Statistical Methods Lynne Stokes Department of Statistical Science Lecture 7: Introduction to SAS Programming Language

2 PreliminariesPreliminaries Create a Folder: c:/Stat6337 Create a Folder: c:/Stat6337 – Send to the Desktop Access Blackboard Access Blackboard Download the Eysenck Data File Download the Eysenck Data File Download the lecture7Eysenck.sas File Download the lecture7Eysenck.sas File Download the lecture7class.sas File Download the lecture7class.sas File Download the lecture7SASSummary.doc File Download the lecture7SASSummary.doc File

3 Eysenck’s Data File

4 Open the SAS Program Double-click the lecture7.sas File Double-click the lecture7.sas File – Press the Run Icon (Runner Image) Editor Editor – Create and Modify SAS Command Files – Can Save in the Stat 6337 Folder : File / Save As … Log Log – Messages about the Compilation and Execution of the SAS Program – Contains Error Messages (in red), if any – Can Save in the Stat 6337 Folder : File / Save As … Output Output – Results of the Execution of the SAS Program – Can Save in the Stat 6337 Folder : File / Save As … To Erase the Contents of the Log or Output Files Right Click, Select “Clear All”

5 SAS Structure DATA Step DATA Step – Describe the data, provide names for variables, define new or transformed variables PROC s : SAS Procedures PROC s : SAS Procedures – Descriptive Statistics: Proc Univariate, Proc Means – Graphics: Proc Chart, Proc Plot – Regression: Proc Reg – Two-sample t-tests: Proc Ttest – Analysis of Variance: Proc Anova, Proc GLM, Proc Mixed – Specialized Data Operations: Proc Sort – etc.

6 SAS Syntax Every command MUST end with a semicolon Every command MUST end with a semicolon – Commands can continue over two or more lines – This WILL be Your #1, #2 & #3 Mistakes !!!! Variable names are 1-8 characters (letters and numerals, beginning with a letter or underscore), but no blanks or special characters Variable names are 1-8 characters (letters and numerals, beginning with a letter or underscore), but no blanks or special characters – Note: values for character variables can exceed 8 characters Comments Comments – Begin with *, end with ; – Can comment several lines: begin with /* and end with */

7 Data Input in the SAS File Data fname ; Data fname ; – creates temporary file with the data that are described in the data step Input name... name $... ; Input name... name $... ; – list input: lists the variable names (1 – 8 characters/letters), name is assumed to be a quantitative variable – name MUST be followed by $ if name is a character variable – alternatives: comma separated, column specified Datalines (or Cards ) ; Datalines (or Cards ) ; – indicates that the data follow, line by line ; – indicates that the last line of data has been input, the semicolon is on a line by itself Example: lecture7class.sas Example: lecture7class.sas – Open lecture7class.sas » Change filename, if necessary – Clear output and log files; Run lecture7class.sas

8 Data Input with Multiple Responses on a Single Line of the Data File SAS Requires that Each Response Value be on a Separate Line of Data SAS Requires that Each Response Value be on a Separate Line of Data When n Responses are on One Line of Data When n Responses are on One Line of Data – Input y1 y2 … yn – y = y1; output; – y = y2; output; –... – y = yn; output; If y1 …yn Represent Responses for n Levels of a Factor If y1 …yn Represent Responses for n Levels of a Factor – Input y1 y2 … yn – factor = ‘Level 1’; y = y1; output; – factor = ‘Level 2’; y = y2; output; –... – factor = ‘Level n’; y = yn; output; Example: Example: lecture7.sas – Data Flow2 Creates n Data Lines with 1 Response Value on Each Line Creates n Data Lines with 1 Factor & Response Value on Each Line

9 Data Input from an External File Filename fn ‘complete directory/file specification’ ; Filename fn ‘complete directory/file specification’ ; filename eysdata ‘c:/Stat6337/EysenckRecall.dat’ – e.g., filename eysdata ‘c:/Stat6337/EysenckRecall.dat’ – Be Careful with Spaces in Directories and File Names !!! Data fname ; Data fname ; – creates temporary file with the data that are described in the data step Infile fn ; Infile fn ; – input the data from the file labeled fn Input name... name $... ; Input name... name $... ; – lists the variable names (1 – 8 characters/letters), name is assumed to be a quantitative variable – name MUST be followed by $ if name is a character variable Run ; Run ; – indicates that the data step is completed Example: Example: lecture7class.sas – Data Recall

10 Program Data Vector One line of data is stored, as indicated on the Input statement of the Data Step One line of data is stored, as indicated on the Input statement of the Data Step Any calculations, deletions, etc. in the Data Step are performed on that line of data Any calculations, deletions, etc. in the Data Step are performed on that line of data When the Data Step is completed, the variables in the Program Data Vector are output to a temporary (work) file When the Data Step is completed, the variables in the Program Data Vector are output to a temporary (work) file Can force data lines to be written at any time with the Output statement Can force data lines to be written at any time with the Output statement

11 Operations in the Data Step Arithmetic Operations Arithmetic Operations – x = u + v ; Transformations Transformations – x = log(y) ; Logical Logical – If x > 0 then z = y/x ; Recoding Recoding – If gender = ‘m’ then gender = ‘Male’; else if gender = ‘f’ then gender = ‘Female’; – Note: SAS formats based on the first value of a variable – To force a length (e.g., character variable), use length

12 Titles and Labels Title# ‘…’ ; Title# ‘…’ ; – Up to 10 title lines: title# ‘include your title here’; – Can be placed in Data Steps or Procs – Changing Title# replaces that title and eliminates Titlex, where x > # Label name = ‘…’ ; Label name = ‘…’ ; – Can be in a Data Step or Proc Print

13 Some Useful PROCs Proc Chart – vertical or horizontal bar charts Proc Freq – frequency distributions, cross tabs Proc Means – select summary statistics Proc Plot – scatterplots Proc Print – prints data files Proc Sort – sorts data files by the values of one or more variables Proc Univariate – a wide range of summary statistics, box plots

14 General Form of PROCs PROC xxxx data=fname options; by groups; proc-specific statements; title... ; output out = fn... ; run ;

15 Printing to the Output File Proc Print data = fname ; Proc Print data = fname ; – var... ;lists the variables to be printed (can be omitted) – run ;indicates the print commands are complete

16 Group Analyses Sort the Groups Sort the Groups – Proc Sort data= … ; – by group; – run; Execute the Proc, by Group Execute the Proc, by Group – Proc xxx data= … ; – by group; –... – run;

17 Summarize the Recall Data Calculate frequencies for each condition/group and each age Proc Freq Graph a histogram of the recall data Proc Chart Calculate the average, standard deviation, minimum, and maximum to 2 decimal places Proc Means

18 Summarize the Recall Data Calculate descriptive statistics for each condition/group Proc Means, Proc Univariate Note: Sort First, then Use the BY Command. Graph Average Recall for All Combinations of Recall Condition/Group and Age Use a Group Identifier as the Plotting Symbol Proc Plot

19 Proc Anova Only for Complete Factorial Experiments in Completely Randomized Designs Only for Complete Factorial Experiments in Completely Randomized Designs – Otherwise: Proc GLM MUST have an Equal Number of Repeats for Each Factor-Level Combination MUST have an Equal Number of Repeats for Each Factor-Level Combination

20 Proc Anova Proc Anova data = fn ; Proc Anova data = fn ; – By … ; » Separate ANOVA Fits for Each Value of the BY variable(s). – Class … ; » List all the factors. – Model … / options; » e.g., model recall = age group age*group ; factors: list individually; e.g. age group interactions: connect with asterisk(s); e.g., age*group – Means … / options; » e.g., means age group age*group / t bon; – Run;

21 Eysenck’s Study of Incidental Learning Make analysis of variance calculations, use only recall condition as factor. Calculate factor-level averages, with the t option.

22 Effect of Cocaine Usage on Newborn Infant Body Lengths Research Question: Do Mean Body Lengths (cm) Differ by Cocaine Usage? Research Question: Do Mean Body Lengths (cm) Differ by Cocaine Usage? Usage Groups: First Trimester Throughout Pregnancy Drug-Free

23 Effect of Cocaine Usage on Newborn Infant Body Lengths

24 AssignmentAssignment Create a Data File Create a Data File Input the Data File into a SAS Program Input the Data File into a SAS Program Cocaine Usage Groups Cocaine Usage Groups – Calculate Averages and Standard Deviations – Make Comparative Box Plots – Test the Equality of the Group Means Me ONLY the FINAL.log File Me ONLY the FINAL.log File