The SAS interface is shown in the following screen shot:

Similar documents
Macro Programming Reference Guide. Copyright 2005 Scott Martinez

PIV Programming. Today s Contents: 1. Matlab Programming 2. An example of PIV in Matlab code 3. EDPIV 4. PIV plugin for ImageJ 5.

Excel Tool: Calculations with Data Sets

Introduction to Statistical Analyses in SAS

The Very Basics of the R Interpreter

Introductory Guide to SAS:

Fathom Dynamic Data TM Version 2 Specifications

PLS205 Lab 1 January 9, Laboratory Topics 1 & 2

A Guide to Using Some Basic MATLAB Functions

STAT 3304/5304 Introduction to Statistical Computing. Introduction to SAS

STAT:5400 Computing in Statistics

STAT 7000: Experimental Statistics I

Graphics calculator instructions

Laboratory Topics 1 & 2

The Graphing Calculator

Lab of COMP 406. MATLAB: Quick Start. Lab tutor : Gene Yu Zhao Mailbox: or Lab 1: 11th Sep, 2013

Algebra 2 Semester 2 Final Exam Study Outline Semester 2 Final Exam Study Tips and Information

Standard Value Calculation with CAPP (PP-BD-CAP)

Beginning Tutorials. PROC FSEDIT NEW=newfilename LIKE=oldfilename; Fig. 4 - Specifying a WHERE Clause in FSEDIT. Data Editing

Variable Definition and Statement Suppression You can create your own variables, and assign them values using = >> a = a = 3.

CLAREMONT MCKENNA COLLEGE. Fletcher Jones Student Peer to Peer Technology Training Program. Basic Statistics using Stata

Functions. Systems Programming Concepts

Math 2250 MATLAB TUTORIAL Fall 2005

St art. modified 17/11/17 1: : : : : : : : : : : : : rp m.

Chapter 1 Introduction to MATLAB

Basic types and definitions. Chapter 3 of Thompson

Stat 302 Statistical Software and Its Applications SAS: Data I/O

Honors Precalculus: Solving equations and inequalities graphically and algebraically. Page 1

Introduction to Programming

Getting started with Stata 2017: Cheat-sheet

Excel R Tips. is used for multiplication. + is used for addition. is used for subtraction. / is used for division

A = [1, 6; 78, 9] Note: everything is case-sensitive, so a and A are different. One enters the above matrix as

A General Introduction to Matlab

ST Lab 1 - The basics of SAS

SAS CURRICULUM. BASE SAS Introduction

CSC 328/428 Summer Session I 2002 Data Analysis for the Experimenter FINAL EXAM

Macro B Reference Guide

LAB 1 General MATLAB Information 1

Physics 326G Winter Class 2. In this class you will learn how to define and work with arrays or vectors.

C Functions. 5.2 Program Modules in C

Stat 302 Statistical Software and Its Applications SAS: Data I/O & Descriptive Statistics

BUSINESS ANALYTICS. 96 HOURS Practical Learning. DexLab Certified. Training Module. Gurgaon (Head Office)

Starting Matlab. MATLAB Laboratory 09/09/10 Lecture. Command Window. Drives/Directories. Go to.

Mastery. PRECALCULUS Student Learning Targets

Contents of SAS Programming Techniques

Secondary Math 3- Honors. 7-4 Inverse Trigonometric Functions

A Short Guide to Stata 10 for Windows

YEAR 12 Core 1 & 2 Maths Curriculum (A Level Year 1)

Introduction to Programming

Introduction. About this Document. What is SPSS. ohow to get SPSS. oopening Data

Introduction to MATLAB 7 for Engineers

10 Using the PCFL Editor In this chapter

A very brief Matlab introduction

PROGRAMMING WITH MATLAB DR. AHMET AKBULUT

Casio fx-cg20. Calculator Instructions A B C D E F G. Contents:

Centering and Interactions: The Training Data

R Introduction 1. J.M. Ponciano. August 17, Objects in Splus language include, and. x<-list(ncolors=2,colors=c("red","blue"))

Watershed Sciences 4930 & 6920 GEOGRAPHIC INFORMATION SYSTEMS

ECON 502 INTRODUCTION TO MATLAB Nov 9, 2007 TA: Murat Koyuncu

9 Using Equation Networks

Bluman & Mayer, Elementary Statistics, A Step by Step Approach, Canadian Edition

Basics of Computational Geometry

Chapter 2: Getting Data Into SAS

Using Microsoft Excel

Software installation

1 Introduction to Matlab

Casio fx-cg20. Calculator Instructions A B C D E F G. Contents:

Matlab Programming Introduction 1 2

Reference and Style Guide for Microsoft Excel

Some elements for Matlab programming

EE3TP4: Signals and Systems Lab 1: Introduction to Matlab Tim Davidson Ext Objective. Report. Introduction to Matlab

FSEDIT Procedure Windows

Matlab Introduction. Scalar Variables and Arithmetic Operators

Lab 1 Intro to MATLAB and FreeMat

Lab #9: ANOVA and TUKEY tests

Introduction to MATLAB for Engineers, Third Edition

Dr Richard Greenaway

Standardized Tests: Best Practices for the TI-Nspire CX

Lecture 2 FORTRAN Basics. Lubna Ahmed

Math 227 EXCEL / MEGASTAT Guide

Introduction to STATA

Base and Advance SAS

FORTRAN Basis. PROGRAM LAYOUT PROGRAM program name IMPLICIT NONE [declaration statements] [executable statements] END PROGRAM [program name]

Reading data in SAS and Descriptive Statistics

CSI31 Lecture 5. Topics: 3.1 Numeric Data Types 3.2 Using the Math Library 3.3 Accumulating Results: Factorial

Single row numeric functions

Excel Spreadsheets and Graphs

A Quick Guide to Stata 8 for Windows

Fact Sheet No.1 MERLIN

Ordinary Differential Equation Solver Language (ODESL) Reference Manual

SCAD Soft. Slope. User manual. Stability analysis of slopes. Version 1.5

General MATLAB Information 1

University of Alberta

Dr Richard Greenaway

ME1107 Computing Y Yan.

I/A Series Software Spreadsheet

Functions and Inverses ID1050 Quantitative & Qualitative Reasoning

Scheme Quick Reference

Starting MATLAB To logon onto a Temple workstation at the Tech Center, follow the directions below.

Computer Programming in MATLAB

Transcription:

The SAS interface is shown in the following screen shot: There are several items of importance shown in the screen shot First there are the usual main menu items, such as File, Edit, etc I seldom use anything but the File and Edit menu items In the File menu there are the typical Open, Close, Save, Print, etc items, while in the Edit menu there is Copy, Paste, Replace, etc For the most part these are all I use The Help menu may or may not be fully functional In the past this would be the approach to opening the SAS online documentation On my current PC I must open the online documentation by going to the START icon, going to All Programs, finding SAS in the list of programs and among the SAS software items is the Documentation On the Command bar (second bar from the top) are a series of icons, the most important of which are the Submit, Clear All and Break (4 th, 3 rd and 2 nd from the last items) If you place the cursor over these icons you will get a brief description of each The submit button submits a set of SAS code that is located in Editor window All programs will originate from the Editor window The Clear All button simply clears all text in the Editor and the Break button will stop SAS processing a set of code This is very useful if you have made a coding mistake that results in an infinite loop or when some SAS procedures are running too long due to model complexity There are typically three windows of importance to SAS programs (only two of the important one are shown in the screen shot I typically close the Explorer window in the left panel The two of importance that are shown are the Editor, where all SAS code goes and the Log, which reports on operation of the SAS All warnings and errors will show up in the Log For this reason it is a good idea to look at the Log for problems The other window of importance is the Output window This is where all of the results from the submitted program will reside You can bring any of the three windows into focus by clicking on the appropriate button at the bottom of the screen (eg, Output, Log and Editor) 1

A Short Course on SAS Commands Before any data can be analyzed, you must make the data available to SAS This is performed in a DATA step Data Input SAS manipulates SAS data files, whether it is to compute the statistics for an analysis of variance or to add two numbers together A SAS data file persists only while the session is running (from the time you load SAS until you terminate the program) Therefore, to perform any analyses using SAS you must first create a SAS data file There are several SAS statements required to create a SAS data file These include the DATA, INPUT, INFILE and CARDS statements Some of these statements have several options available All SAS statements end with a semicolon There are essentially two methods of creation: either in the program stream or from an external data file The general form of a data step with the data entered in the program stream is: DATA filename; INPUT variable_1 variable_2 @@@ variable_n; SAS statement_1; SAS statement_2; SAS statement_n; CARDS; data row 1 data row 2 data row n ; RUN; The general form of a data step with the data entered from an external file is: DATA filename; INFILE path and filename options; INPUT variable_1 variable_2 @@@ variable_n; SAS statement_1; SAS statement_2; SAS statement_n; RUN; For all programs developed over the next several pages only the first approach will be used 2

The SAS statements in the DATA step: DATA filename; INFILE path and file name options; INPUT variable_1, variable_2, @@@, variable_n; CARDS; or DATALINES; Initializes the data step and assigns the filename to the SAS data file Data will be read from an external file The path and file name are specified in quotes Two main options are of use here: dlm = character and firstobs = n The character in the dlm option is typically a comma since this is the separator between columns of a comma separated value file (MS Excel data type) The firstobs option indicates from which row of the data file to start reading Here n is an integer Variables variable_1, variable_2, @@@, variable_n are to be created using in-stream data entry There are several options available for the INPUT statement, but only a couple will be discussed Data may be numeric or character The default data type is numeric Character data must be followed by a $ If data are missing, use a period The @@ character at the end of an INPUT statement allows for data to be read in multiple complete sets from the same data line Indicates that the data are to be entered in-stream and directly follow the CARDS statement SAS Statements in the data step can be used to manipulate data or create new variables These SAS Statements appear in the data step following the INPUT statement These SAS statements can be arithmetic, logical or functional in nature Arithmetic Operators operator function example ** raise to a power X = Y**Z; * multiplication X = Y*Z; / division X = Y/Z; + addition X = Y + Z; - subtraction X = Y - Z; Comparison Operators operator function example = or EQ equal to if Y = Z then X = 2; ^= or NE not equal to if Y ^= Z then X = 2; > or GT greater than if Y > Z then X = 2; < or LT less than if Y< Z then X = 2; >= or GE greater than or equal to if Y >= Z then X = 2; <= or LE less than or equal to if Y <= Z then X = 2; 3

Logical Operators operator function example & or AND intersection of two logicals if Y = Z AND X = 2 then W = X; or OR union of two logicals if Y = Z OR X = 2 then W = X; ^ or NOT complement if NOT (Y = 2) then W = X; SAS Functions SAS function can be applied to variables or constants For example, suppose you wanted to create a new variable X that was the natural logarithm of the variable Y The functional form would be: X = LOG(Y); Here, LOG is the function for the natural logarithm and Y is the argument The argument can be either a defined variable or a constant A Survey of SAS Functions function definition ABS Absolute value SQRT Square root ROUND Rounds to the nearest roundoff unit LOG Natural logarithm LOG10 Logarithm base 10 ARCOS Arc-cosine ARSIN Arc-sine ATAN Arc-tangent COS Cosine SIN Sine TAN Tangent POISSON Poisson probability distribution function (cumulative probability) PROBBNML Binomial probability distribution function (cumulative probability) PROBCHI Chi-square probability distribution function (cumulative probability) PROBF F probability distribution function (cumulative probability) PROBNORM Standard normal probability distribution function (cumulative probability) PROBT T probability distribution function (cumulative probability) CINV Inverse of the chi-square distribution function (quantile) FINV Inverse of the F distribution function (quantile) PROBIT Inverse of the normal distribution function (quantile) TINV Inverse of the T distribution function (quantile) 4

SAS Procedures The effectiveness of SAS as a statistical software package lies in the union of the ability to manipulate data in the data step and then send the data to a procedure for further analysis SAS procedures are essentially functions However, unlike the functions just described, SAS procedures are far more complex and produce and array of output All SAS procedure call begin with the key work PROC Some of the basic statistical procedures supplied by SAS include PROC UNIVARIATE, PROC GLM, PROC REG, PROC PLOT PROC ANOVA PROC MIXED and PROC LOGISTIC There are many more SAS PROCs, too many to discuss here The procedures of interest to the analysis of variance include: PROC GLM PROC ANOVA PROC MIXED PROC UNIVARIATE PROC PLOT PROC SORT PROC TTEST PROC REG general linear models procedure for analysis of variance and regression analysis of variance procedure mixed model analysis of variance procedure univariate statistics and tests for normality X, Y scatter plot procedure sort data in ascending or descending order perform both an independent two sample t-test and a paired t-test regression analysis procedure The use of arithmetic operators, comparison operators, logical operators, SAS functions and SAS procedures are discussed in detail within the online documentation You should explore these pages for your own benefit The arithmetic operators, comparison operators, logical operators, SAS functions can be found in the Base SAS pages, while the procedures documentation can be found in the SAS/STAT pages (near the bottom of the list) Now that you have some understanding of the lay-out of SAS, it is time to create a SAS data set and use a procedure Example 1 - SAS Data File Creation Using In-Stream Data Entry: In the following example, a SAS data set named new will be created with variables X, Y and Z X will be numeric, while Y and Z will be character variables SAS reads data line by line, reading from left to right The data set new is printed (results will appear in the Output window) using the Print procedure To invoke a procedure you simply use the term proc followed by the procedure name Each procedure will have many possible options or statements For the Print procedure the only option used is specification of the data set to use, new in this case data new; input X Y $ Z $; cards; 10 Kim Forester 15 Jim Green 25 Peter Zanis ; Proc Print data = new; run; The Proc Print data = new; and run; statements are not needed for the data step, they are needed to see the results of the data step 5

Entering the example SAS code into the SAS Editor window and clicking on the Submit button produces the following screen shot: 6