EPI204 – Lab Session 1 EPI204. LAB SESSION 1 March 26-March 28, 2014 LINEAR REGRESSION The Lab 1 session aims to demonstrate the SAS statements and procedures used to run linear regression models. OUTLINE 1. Data exploration 2. Linear Regression Model 3. Linear Models: The REG procedure (PROC REG) 4. General Linear Models: The GLM procedure (PROC GLM) For lab session 1, we will be using the NHANES 2 data. The dataset for this lab session only is named lab1.sas7bdat (“Lab 1 – Data”) and you can find it under the “Lab sessions 2014” page in the course website. Save it in your P drive or in another location. The variables we will be using today are the following: Variable Name Description height height in centimeters (cm) wt weight in kilograms sex sex (boys 1; girls 0) race race (white 1; black 2; other 3) fvc forced vital capacity 0. Introduction to SAS 1.1. When you open SAS, you will see three tabs: - Editor: This window is a text editor where you will write, submit, and edit your code. - Log: This will contain any notes, error messages, and warnings associated with running your program. You should ALWAYS look at your log every time you run a program. - Output: If your program generates printable results, they will appear here. On the left hand side of the screen you will see a bar that also contains two tabs: - Explorer: The file tree found in this tab allows you to navigate to and view your datafiles. - Results: The file tree found in this tab allows you to navigate to the particular piece of output that you want to view (provided you have output). 0.2 Specify a library. libname EPI204 "P:\ " ; (or the location where you saved the lab1.sas7bdat file) 1
EPI204 – Lab Session 1 Put the path name for the folder where you saved the dataset for this lab. Assigning a libname (i.e. library name) to this allows you to reference this path name without typing it out again and again. Any time SAS sees “EPI204” it will automatically substitute “P:\”, which saves you lots of typing. Mostly we will use this library to import and save permanent datasets. 0.3 Create a working dataset, see what is in it SAS has two types of datasets – permanent and working. Permanent datasets are stored in whatever library you specify. Working datasets are stored in the library WORK and are temporary – they get deleted when you close SAS. You should always read in your permanent dataset, copy it into a working dataset and then make changes to the copy. Never make changes to your original data file. At the end, you can either re-run the program to recreate your working dataset or save your copy as a new permanent dataset. Here we copy the lab1 dataset into a temporary dataset we call original . data original; set EPI204.lab1; run ; Click on “Explorer” on the left hand side of the screen, and then click on “Libraries” folder. You should see the “original” file you just created in the “Work” folder.