Epidemiology Principles of Biostatistics Chapter 3. Introduction to SAS. John Koval

Similar documents
SAS Training Spring 2006

Using an ICPSR set-up file to create a SAS dataset

STAT:5400 Computing in Statistics

ECLT 5810 SAS Programming - Introduction

Lab #1: Introduction to Basic SAS Operations

TYPES OF VARIABLES, STRUCTURE OF DATASETS, AND BASIC STATA LAYOUT

SAS PROGRAMMING AND APPLICATIONS (STAT 5110/6110): FALL 2015 Module 2

Example1D.1.sas. * Procedures : ; * 1. print to show the dataset. ;

A Guided Tour Through the SAS Windowing Environment Casey Cantrell, Clarion Consulting, Los Angeles, CA

Introductory Guide to SAS:

Introduction to the SAS System

DEPARTMENT OF HEALTH AND HUMAN SCIENCES HS900 RESEARCH METHODS

Introduction to Stata Toy Program #1 Basic Descriptives

STAT 7000: Experimental Statistics I

ssh tap sas913 sas

Getting Up to Speed with PROC REPORT Kimberly LeBouton, K.J.L. Computing, Rossmoor, CA

I Launching and Exiting Stata. Stata will ask you if you would like to check for updates. Update now or later, your choice.

Intermediate SAS: Working with Data

%Addval: A SAS Macro Which Completes the Cartesian Product of Dataset Observations for All Values of a Selected Set of Variables

Stata v 12 Illustration. First Session

PROC FORMAT. CMS SAS User Group Conference October 31, 2007 Dan Waldo

Introduction to Stata First Session. I- Launching and Exiting Stata Launching Stata Exiting Stata..

STAT 503 Fall Introduction to SAS

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

Analysis of variance and regression. November 13, 2007

Analysis of variance and regression. November 13, 2007

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

Reading data in SAS and Descriptive Statistics

ST Lab 1 - The basics of SAS

Checking the Math Data

Lecture 1 Getting Started with SAS

1 The SAS System 23:01 Friday, November 9, 2012

TIPS FROM THE TRENCHES

Introduction to Stata

Multiple Facts about Multilabel Formats

Stata version 13. First Session. January I- Launching and Exiting Stata Launching Stata Exiting Stata..

Introduction to SAS: General

Introduction to Minitab 1

April 4, SAS General Introduction

data Vote; /* Read a CSV file */ infile 'c:\users\yuen\documents\6250\homework\hw1\political.csv' dsd; input state $ Party $ Age; run;

Introduction to SAS Statistical Package

Some Basics of CQUEST

EXAMPLE 2: INTRODUCTION TO SAS AND SOME NOTES ON HOUSEKEEPING PART II - MATCHING DATA FROM RESPONDENTS AT 2 WAVES INTO WIDE FORMAT

BIOSTATISTICS LABORATORY PART 1: INTRODUCTION TO DATA ANALYIS WITH STATA: EXPLORING AND SUMMARIZING DATA

QUEST Procedure Reference

Introduction. How to Use this Document. What is SAS? Launching SAS. Windows in SAS for Windows. Research Technologies at Indiana University

1 Downloading files and accessing SAS. 2 Sorting, scatterplots, correlation and regression

Introduction to SAS Mike Zdeb ( , #61

(on CQUEST) A.L. Gibbs

(on CQUEST) A.L. Gibbs

Chapter 1: Introduction to SAS

INTRODUCTION SAS Prepared by A. B. Billings West Virginia University May 1999 (updated August 2006)

Introduction to SAS. Cristina Murray-Krezan Research Assistant Professor of Internal Medicine Biostatistician, CTSC

Statements with the Same Function in Multiple Procedures

Lab #3. Viewing Data in SAS. Tables in SAS. 171:161: Introduction to Biostatistics Breheny

Exam Questions A00-281

Introduction to SAS Procedures SAS Basics III. Susan J. Slaughter, Avocet Solutions

Introductory SAS example

CH5: CORR & SIMPLE LINEAR REFRESSION =======================================

Going Under the Hood: How Does the Macro Processor Really Work?

SAS Programs SAS Lecture 4 Procedures. Aidan McDermott, April 18, Outline. Internal SAS formats. SAS Formats

COPYRIGHTED MATERIAL GETTING STARTED LEARNING OBJECTIVES

Appendix II: STATA Preliminary

You will learn: The structure of the Stata interface How to open files in Stata How to modify variable and value labels How to manipulate variables

A Practical Introduction to SAS Data Integration Studio

SAS Display Manager Windows. For Windows

Introduction to SAS Procedures SAS Basics III. Susan J. Slaughter, Avocet Solutions

APPENDIX 4 Migrating from QMF to SAS/ ASSIST Software. Each of these steps can be executed independently.

Introduction to STATA 6.0 ECONOMICS 626

A Simple Guide to Using SPSS (Statistical Package for the. Introduction. Steps for Analyzing Data. Social Sciences) for Windows

Lab 1: Introduction to Data

Getting Your Data into SAS The Basics. Math 3210 Dr. Zeng Department of Mathematics California State University, Bakersfield

2. Don t forget semicolons and RUN statements The two most common programming errors.

Stata: A Brief Introduction Biostatistics

ABSTRACT INTRODUCTION PROBLEM: TOO MUCH INFORMATION? math nrt scr. ID School Grade Gender Ethnicity read nrt scr

A Step by Step Guide to Learning SAS

Create a SAS Program to create the following files from the PREC2 sas data set created in LAB2.

STA 303 / 1002 Using SAS on CQUEST

/23/2004 TA : Jiyoon Kim. Recitation Note 1

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

3. Almost always use system options options compress =yes nocenter; /* mostly use */ options ps=9999 ls=200;

Overview of Data Management Tasks (command file=datamgt.sas)

1 Files to download. 3 Macro to list the highest and lowest N data values. 2 Reading in the example data file

1. Creating a data set using the data editor 2. Importing an Excel data file

Seminar Series: CTSI Presents

Chapter 6 Creating Reports. Chapter Table of Contents

Econ Stata Tutorial I: Reading, Organizing and Describing Data. Sanjaya DeSilva

EXST SAS Lab Lab #6: More DATA STEP tasks

LAB 1 INSTRUCTIONS DESCRIBING AND DISPLAYING DATA

PDQ-Notes. Reynolds Farley. PDQ-Note 3 Displaying Your Results in the Expert Query Window

Routing the SAS Log and SAS Procedure Output

Introduction to SAS Programs. Objectives. SAS Programs. Sample Data. File Containing Data: boxhunter.dat

International Graduate School of Genetic and Molecular Epidemiology (GAME) Computing Notes and Introduction to Stata

The DATA Statement: Efficiency Techniques

INTRODUCTION to SAS STATISTICAL PACKAGE LAB 3

CMU MSP : SAS FORMATs and INFORMATs Howard Seltman Nov. 7+12, 2018

Cleaning up your SAS log: Note Messages

PHPM 672/677 Lab #2: Variables & Conditionals Due date: Submit by 11:59pm Monday 2/5 with Assignment 2

Level 6 Relational Database Unit 3 Relational Database Development Environment National Council for Vocational Awards C30147 RELATIONAL DATABASE

ISETL Getting Started Guide

Transcription:

Epidemiology 9509 Principles of Biostatistics Chapter 3 John Koval Department of Epidemiology and Biostatistics University of Western Ontario

What we will do today We will learn to use use SAS to 1. read raw data 2. create word descriptions of the data 3. perform some simple statistics

Many windows (6) 1. toolbar 2. explorer 3. results 4. editor 5. log 6. output Initially 4 are visible toolbar explorer editor log

Programming process 1. use editor to prepare program 2. submit 3. look at log and output 4. decide to use editor to modify program 5. etc

Running SAS Figure 3.1: Process for running SAS Editor SAS program SAS errors Log window output Output window more?

Notation KEYWORD user info; example DATA name; 1. KEYWORD SAS command 2. user info specific to your analysis 3. ; the blessed SAS semi-colon could be data name;

General pattern 1. preamble 2. data step (DATA) 3. procedure (PROC)

Preamble 1. TITLE 2. OPTIONS 3. FILENAME

TITLE statement prints at beginning of each page of output TITLE Worlds greatest analysis ; TITLE1 Worlds greatest analysis ; TITLE2 for my thesis of course ;

OPTIONS for example, to change output OPTIONS LINESIZE=80 PAGESIZE=60; shortens output to fit on letter-size pages 1. LINESIZE=80 no more than 80 characters on a page 2. PAGESIZE=60 no more than 60 lines per page short form is OPTIONS ls=80 ps=60;

FILENAME statement indicates location of file needed by SAS FILENAME one one.dat ; looks for file one.dat in c:\documents and Settings\yourname or FILENAME one U:\one.dat ; looks for one.dat on U: drive one is SAS name for file one.dat is Windoze name for file

Other SAS statements 1. Comments 2. RUN 3. QUIT 4. ENDSAS

Comments in code only does not print out (go to OUTPUT window) 1. on a line by itself * look at this brilliant SAS code; 2. at end of a line of the program PROC FREQ /* twoway tables */;

RUN QUIT and ENDSAS 1. RUN RUN; 1.1 to run SAS program that proceeds 1.2 at end of SAS program to complete run of all commands 1.3 can highlight code and SUBMIT 2. QUIT QUIT; 2.1 at end of SAS program to run all commands 2.2 stop runaway program 3. ENDSAS ENDSAS; AVOID kills SAS session

The Data step 1. DATA 2. DATALINES 3. INPUT 4. LABEL

DATA statement DATA first; creates temporary SAS dataset first.sas7bdat in WORK folder

DATALINES statement brings data into SAS program DATALINES; 1 22 1 60 2 25 1 80... 6 23 2 70 ; semicolon(;) at end of data

INPUT statement short names of variables INPUT id age sex hr;

LABEL statement extended names of variables LABEL id = Unique identification number hr = heart rate ; semicolon (;) at end of all labels in LABEL statement

SAS Procedures doing the statistics 1. PROC PRINT 2. PROC MEANS 3. PROC FREQ 4. PROC FORMAT

PROC PRINT gives a list of values of indicated variables shortening output to only first M cases PROC PRINT DATA=first (OBS=4); VAR age sex;

PROC MEANS mean, variance, standard deviation minimum, maximum PROC MEANS; VAR age hr;

PROC FREQ frequencies, relative frequencies cumulative frequencies, cumulative relative frequencies PROC FREQ; TABLE sex;

Formats giving meaning values to numerical values of discrete data 1. PROC FORMAT 2. FORMAT statment

PROC FORMAT defines formats for rest of SAS session appears before use in FORMAT statement can appear before DATA step PROC FORMAT VALUE sex 1= Male 2= Female VALUE yesno 1= Yes 2= No ;

FORMAT Statement 1. PROC 2. DATA step FORMAT sex sex. q1 yesno.

A SAS program title First SAS program ; options pagesize=60 linesize=80; proc format; value gender 1= Male 2= Female ; data first; input id age sex hr; label age= Age of Subject sex= Sex of Subject hr= Heart Rate ; format sex gender.;

A SAS program (continued) datalines; 1 22 1 60 2 25 1 80 3 24 1 75 4 27 2 55 5 26 2 65 6 23 2 70 ; proc means; var age; proc freq; table sex; run;

Sample output file First SAS program 1 17:12 Wednesday, September 7, 2011 The MEANS Procedure Analysis Variable : age Age of Subject N Mean Std Dev Minimum Maximum ------------------------------------------------- 6 24.5000000 1.8708287 22.0000000 27.0000000 --------------------_---------------------------- SAS sample program 2 The FREQ Procedure Sex of Subject Cumulative Cumulative sex Frequency Percent Frequency Percent ----------------------------------------------------- Male 3 50.00 3 50.00 Female 3 50.00 6 100.00

Sample log file NOTE: Copyright (c) 2002-2008 by SAS Institute Inc., Cary, NC, USA. NOTE: SAS (r) Proprietary Software 9.2 (TS2M3) NOTE: SAS initialization used: real time 25.68 seconds cpu time 6.73 seconds 1 title First SAS program ; 2 options pagesize=60 linesize=80; 3 proc format; 4 value gender 1= Male 2= Female ; NOTE: Format GENDER has been output. NOTE: PROCEDURE FORMAT used (Total process time): real time 0.38 seconds cpu time 0.14 seconds

Sample log file - continued 5 data first; 6 input id age sex hr; 7 label age= Age of Subject 8 sex= Sex of Subject 9 hr= Heart Rate ; 10 format sex gender.; 11 datalines; NOTE: The data set WORK.FIRST has 6 observations and 4 variables. NOTE: DATA statement used (Total process time): real time 1.91 seconds cpu time 0.36 seconds 18 ; 19 proc means; 20 var age;

Sample log file - III NOTE: There were 6 observations read from the data set WORK.FIRST. NOTE: PROCEDURE MEANS used (Total process time): real time 1.50 seconds cpu time 0.34 seconds 21 proc freq; 22 table sex; 23 run; NOTE: There were 6 observations read from the data set WORK.FIRST. NOTE: PROCEDURE FREQ used (Total process time): real time 0.82 seconds cpu time 0.15 seconds

REMEMBER Save 1. your SAS program often 2. your output file when you have a successful run Save on the U: drive