/********************************************** This command file is to do the problems for Biostat 510 homework 1. filename: homework1.sas ***********************************************/ /*Import Excel File: HRTRATE1.XLS*/ PROC IMPORT OUT= WORK.HRTRATE1 DATAFILE= "f:\510\homework\hrtrate1.xls" DBMS=EXCEL REPLACE; SHEET="Sheet1$"; GETNAMES=YES; MIXED=NO; SCANTEXT=YES; USEDATE=YES; SCANTIME=YES; RUN; /*Import Excel File: HRTRATE2.XLS*/ PROC IMPORT OUT= WORK.HRTRATE2 DATAFILE= "f:\510\homework\hrtrate2.xls" DBMS=EXCEL REPLACE; SHEET="Sheet1$"; GETNAMES=YES; MIXED=NO; SCANTEXT=YES; USEDATE=YES; SCANTIME=YES; RUN; /*Get descriptive Statistics for both data sets*/ proc means data=hrtrate1; run; proc means data=hrtrate2; run; /*get frequencies for categorical variables*/ proc freq data=hrtrate1; tables monbir daybir yearbir gender department; run; proc freq data=hrtrate2; tables ran; run; /*Get univariate statistics and histograms for continuous variables*/ proc univariate data=work.hrtrate1 plot; where weight between 10 and 300; var yearbir monbir height weight hrs_exercise distance hrtrate1; histogram; run; proc univariate data=work.hrtrate2 plot; var hrtrate2; histogram; run; /*Save Permanent SAS data sets and create new variables*/ libname b510 v9 "f:\510\homework"; data b510.hrtrate1; set work.hrtrate1; if weight = 999 then weight=.; wtkg = weight / 2.2; if ht_units="cm" then htcm=height; if ht_units="in" then htcm=height*2.54; BMI = wtkg/(htcm/100)**2; run; data b510.hrtrate2; set work.hrtrate2; if id = 999 then id = .; run; /*Get information on permanent data set: b510:hrtrate1*/ proc means data=b510.hrtrate1; where wtkg > 10; run; proc print data=b510.hrtrate1(obs=10); run; proc contents data=b510.hrtrate1; run; proc univariate data=b510.hrtrate1; where wtkg >10; var wtkg; histogram; run; /*Get descriptives, etc on permanent data set: b510.hrtrate2*/ proc means data=b510.hrtrate2; run; proc print data=b510.hrtrate2(obs=10); proc contents data=b510.hrrate2; run;