bmtry 789 introduction to sas programming

15
BMTRY 789 Introduction to SAS Programming Lecturer: Annie N. Simpson, MSc.

Upload: eric-gould

Post on 31-Dec-2015

28 views

Category:

Documents


0 download

DESCRIPTION

BMTRY 789 Introduction to SAS Programming. Lecturer: Annie N. Simpson, MSc. Syllabus. DEPARTMENT: Biostatistics, Bioinformatics, and Epidemiology PRINCIPAL INSTRUCTOR: A. Simpson, MSc. METHODS OF EVALUATION: Pass/No Pass (2 Credit Hours) Homework Assignments 70% - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: BMTRY 789  Introduction to SAS Programming

BMTRY 789 Introduction to SAS Programming

Lecturer: Annie N. Simpson, MSc.

Page 2: BMTRY 789  Introduction to SAS Programming

Summer 2008 BMTRY 789 Intro. To SAS Programming 2

Syllabus DEPARTMENT: Biostatistics, Bioinformatics, and Epidemiology PRINCIPAL INSTRUCTOR: A. Simpson, MSc. METHODS OF EVALUATION: Pass/No Pass (2 Credit Hours)

Homework Assignments 70%Class Preparation and Participation 20%Group Presentation 10%

READINGS: Readings assigned for a class are expected to be read prior to that class session.

REQUIRED TEXT: Applied Statistics and the SAS Programming Language. Cody R.P. and Smith, J.K. (5th Edition) 2006. Prentice Hall, Upper Saddle River, NJ 07458.

WHEN OFFERED: Summer Semester, 12 weeks, Wed 10:00am-12:30pm

Page 3: BMTRY 789  Introduction to SAS Programming

Summer 2008 BMTRY 789 Intro. To SAS Programming 3

Syllabus (cont.) METHODS OF EVALUATION: Pass/No Pass (2 Credit Hours)

Class Preparation and Participation 20%

Homework (70%): : Homework is the main method of evaluation (AND

PRACTICE!) 7-9 HWS, 1 free miss, 4 “√-” or less = your pass is in jeopardy (depending on attendance and final presentation).

Attendance (20%): Attendance is required. If ≥3 of the 11 classes are

missed you will automatically not pass. Final Presentation (10%):

Required: No final presentation, no pass

Page 4: BMTRY 789  Introduction to SAS Programming

Summer 2008 BMTRY 789 Intro. To SAS Programming 4

What are your expectations?

Page 5: BMTRY 789  Introduction to SAS Programming

Summer 2008 BMTRY 789 Intro. To SAS Programming 5

Syllabus (cont.)DETAILED STATEMENT OF OBJECTIVE: To introduce students to the concepts and methods of

programming using SAS, and to expose them to other statistical software packages through guest lecturers. At the end of the course, the student will be able to:

1.      Read basic SAS syntax and functions;

2.      Enter raw data and import data from other sources into SAS;

3.      Manipulate SAS data to construct flat and vertical files structured to answer specific research questions;

4.      Program procedures to describe the characteristics of continuous and categorical variables;

5.      Be aware of other software packages and the conditions under which they may be superior to SAS for analytical purposes;

6.      Be able to debug programs and to use assorted references, both online and text, to learn new SAS procedures and functions, as well as solve programming challenges.

7.      Be familiar with individuals at MUSC with extensive experience in data manipulation, SAS and other programming languages.

Page 6: BMTRY 789  Introduction to SAS Programming

Summer 2008 BMTRY 789 Intro. To SAS Programming 6

CLASS SCHEDULE Lecture Date Title Readings

1 5/21 Overview of SAS None

2 5/28 SAS syntax, variable naming rules, entering your own data, and Input Statement

Chapter 1, 2, 12 & 13

6/4 No Class on this day, but HW 1 is still due by 5pm in Annie’s mailbox

3 6/11 Categorical data and working with dates and longitudinal data

Chapters 3 & 4

4 6/18 Subsetting, Merging, Construction of Flat Files from Vertical, etc.

Chapter 14

5 6/25 Random Number Generators, If-Then_Else and Do Loops

Chapter 5 & 6

6 7/2 Conquering Proc gPLOT, Output Statements and the Output Delivery System (ODS)

Chapter 7 & Selected Readings

7 7/9 SAS Functions, especially dealing with dates

Chapters 17 & 18

Page 7: BMTRY 789  Introduction to SAS Programming

Summer 2008 BMTRY 789 Intro. To SAS Programming 7

CLASS SCHEDULE (cont.)

Lecture Date Title Readings

8 7/16 Arrays and Advanced Analytical Data set Creation

Chapter 2 & 3

9 7/23 Intro. To Macro Programming (S. Shaftman)

Chapters 19 & Selected Readings

10 7/30 Scoring a Test and Proc Tabulate Chapter 11 & Selected Readings

11 8/6 Debugging your Code AND Final Presentations on Pieces of Useful SAS Code and/or tricks

None

Page 8: BMTRY 789  Introduction to SAS Programming

Summer 2008 BMTRY 789 Intro. To SAS Programming 8

SAS Help Resources

Nothing replaces experience / trial and error

Help files from the program, all the manuals you could ever want or need!

SAS Books by users (I have a shelf full)

SAS on the web: www.SAS.com

Page 9: BMTRY 789  Introduction to SAS Programming

Summer 2008 BMTRY 789 Intro. To SAS Programming 9

Example*Import Data using the File->Import Data pull down menu;

*Call the new SAS data set STROKE;

*Add a new hypertension indicator to the data set based on bp;

*Print the new data set out to the screen;

Libname Annie “C:\DATA”;

DATA Annie.Stroke;

Set Stroke;

If sbp > 140 and dbp > 90 then Hypertensive=1;

Else If sbp = . Or dbp = . Then Hypertensive=.;

Else Hypertensive = 0;

RUN;

PROC PRINT DATA = Annie.Stroke; /*Prints the results*/

RUN;

Page 10: BMTRY 789  Introduction to SAS Programming

Summer 2008 BMTRY 789 Intro. To SAS Programming 10

Commenting Your Code

Comments are usually used to annotate the program, making it easier for someone to read your program and understand what you have done and why.

YOU WILL NOT GET FULL CREDIT IN THIS CLASS IF YOUR CODE ISN’T VERY WELL COMMENTED!

Page 11: BMTRY 789  Introduction to SAS Programming

Summer 2008 BMTRY 789 Intro. To SAS Programming 11

Rows/Columns & Data Types

What is the SAS lingo for Rows of Data?

What is the SAS lingo for Columns? What are the two types of data? Where do dates fit in?

Page 12: BMTRY 789  Introduction to SAS Programming

Summer 2008 BMTRY 789 Intro. To SAS Programming 12

Rules for SAS names How long (# of characters) can

variable names be? What are the two things that can

begin a variable name? What can NOT be contained in a

variable name? Is SAS case sensitive? When?

Page 13: BMTRY 789  Introduction to SAS Programming

Summer 2008 BMTRY 789 Intro. To SAS Programming 13

Reading the SAS Log

Every time you run a SAS job, READ the Log window first!

Every time you have a question for me I will ask, “What does you SAS Log say?”.

Page 14: BMTRY 789  Introduction to SAS Programming

Summer 2008 BMTRY 789 Intro. To SAS Programming 14

Let’s go over how to use the SAS Import Wizard to get Excel Data into SAS…

Open the Import Wizard Instructions.

Page 15: BMTRY 789  Introduction to SAS Programming

Summer 2008 BMTRY 789 Intro. To SAS Programming 15

Test Your SAS Knowledge Find the class 1 in-class

assignment from the class website.http://people.musc.edu/~simpsona/SASclass/

Class_Notes.html

Use the Excel Data file to complete the questions.

For brand new SAS programmers we will do this together.