Docsity

Biostat 510 Homework 1: Importing and Analyzing Excel Data in SAS - Prof. Kathleen B. Welc, Assignments of Biostatistics

Toggle sidebar
bg1
Biostat 510
Homework 1
Due Tuesday, January 15, 2008
1. Download the Excel files for the groups from the first day of class. Save them in a folder
that you will be able to access later. They are in the Biostat 510 section of my web page
at http://www.umich.edu/~kwelch.
2. Check the data in the Excel files, fix any problems, and resave the fixed files.
a) Open each file in Excel and make sure the first row of the Excel file contains the
variable names.
b) Make sure there are no empty rows between row 1 and the rows containing the
data.
c) Note the Sheet name on the tab at the bottom of the worksheet.
d) Make sure all variable names are spelled the same way in all Excel files, and that
there are no blanks in the variable names.
You should have the following variables in each Excel file:
Variable Name Description
GROUP Numeric
ID Numeric
SEX M and F
BORN Character Values
DISTANCE Numeric
RAN 1= Ran, 2=Did not run
HR1 Heartrate 1
HR2 Heartrate 2
(upper and lower case for the variable names do not matter).
e) Resave each of the Excel files after you have made any corrections.
f) Close all the Excel files before importing them into SAS.
3. Use the Import Wizard to import the Excel files into SAS.
a) Import group1.xls into SAS, and save it as a temporary data set called
WORK.group1.
b) Save the commands that you used to import the data in a command file called
homework1.sas.
c) Open the homework1.sas commands in the SAS Enhanced Program Editor
window, by going to File…Open program… and browsing to where you saved
the commands. The commands that were used to import the group1.xls file should
look something like those shown below:
PROC IMPORT OUT= WORK.Group1
DATAFILE= "C:\510\2008\group1.xls"
DBMS=EXCEL REPLACE;
1
pf3

Partial preview of the text

Download Biostat 510 Homework 1: Importing and Analyzing Excel Data in SAS - Prof. Kathleen B. Welc and more Assignments Biostatistics in PDF only on Docsity!

Biostat 510

Homework 1

Due Tuesday, January 15, 2008

  1. Download the Excel files for the groups from the first day of class. Save them in a folder that you will be able to access later. They are in the Biostat 510 section of my web page at http://www.umich.edu/~kwelch.
  2. Check the data in the Excel files, fix any problems , and resave the fixed files. a) Open each file in Excel and make sure the first row of the Excel file contains the variable names. b) Make sure there are no empty rows between row 1 and the rows containing the data. c) Note the Sheet name on the tab at the bottom of the worksheet. d) Make sure all variable names are spelled the same way in all Excel files , and that there are no blanks in the variable names. You should have the following variables in each Excel file: Variable Name Description GROUP Numeric ID Numeric SEX M and F BORN Character Values DISTANCE Numeric RAN 1= Ran, 2=Did not run HR1 Heartrate 1 HR2 Heartrate 2 (upper and lower case for the variable names do not matter). e) Resave each of the Excel files after you have made any corrections. f) Close all the Excel files before importing them into SAS.
  3. Use the Import Wizard to import the Excel files into SAS. a) Import group1.xls into SAS, and save it as a temporary data set called WORK.group1. b) Save the commands that you used to import the data in a command file called homework1.sas. c) Open the homework1.sas commands in the SAS Enhanced Program Editor window, by going to File…Open program… and browsing to where you saved the commands. The commands that were used to import the group1.xls file should look something like those shown below: PROC IMPORT OUT= WORK.Group DATAFILE= "C:\510\2008\group1.xls" DBMS=EXCEL REPLACE;

SHEET="Sheet1$"; GETNAMES=YES; MIXED=NO; SCANTEXT=YES; USEDATE=YES; SCANTIME=YES; RUN; Note: you do not have to type the commands as shown above if you use the Import Wizard in SAS. The import Wizard will automatically create the commands and save them in your command file. See the handout on my web page for instructions on how to use the Import Wizard to import an Excel file. d) Browse the Group1 data set in the VIEWTABLE Window in SAS to be sure it has been imported correctly. e) Close the viewtable view of the data set in SAS, being careful not to close all of SAS in the process, and return to the Enhanced Program Editor window. f) In the SAS Enhanced Program Editor window, copy and paste the SAS commands for group1 , and modify them to create the data sets for the remaining groups, they will be called WORK.group2, WORK.group3, etc. i. Make sure the data set name is specified correctly for each group. ii. Make sure the sheet name is specified correctly for each group. g) Submit the PROC IMPORT commands for the remaining data sets. h) Check the SAS log to be sure there are no errors.  Include the portion of your SAS log showing the successful importation of the Group 7 data in your homework write-up.

  1. Combine the data sets for all groups by stacking them into one temporary data set, using a SET statement in SAS. Your SAS commands will look something like those shown below (e.g. for 3 groups): data WORK.allgroups; set group1 group2 group3; run; a) Browse your Allgroups data set. b) If there is a problem in creating your data set, go back and fix it, and recreate the data set by highlighting and resubmitting your commands.  Include the portion of your SAS log showing the successful creation of the Allgroups data set.