/********************************************** This example shows how to import an Excel File, set up missing value codes and create some new variables. New variables are also created. Filename: descriptives.sas **********************************************/ PROC IMPORT OUT= WORK.OWEN DATAFILE= "C:\temp\labdata\OWEN.XLS" DBMS=EXCEL REPLACE; SHEET="OWEN$"; GETNAMES=YES; MIXED=NO; SCANTEXT=YES; USEDATE=YES; SCANTIME=YES; RUN; proc means data=owen; title "Descriptive Statistics for All Numeric Variables"; run; data owen2; set owen; if vit_a = 99 then vit_a = .; if head_cir = 99 then head_cir = .; if fatfold = 99 then fatfold = .; if b_weight = 999 then b_weight= .; if mot_age = 99 then mot_age = .; if b_order_ = 99 then b_order_ = .; if m_height = 999 then m_height=.; if f_height = 999 then f_height=.; rename b_order_ = b_order; bwt_g = b_weight*10; /*NOTE: THE CODE BELOW TAKES MISSING INTO ACCOUNT*/ if bwt_g not=. and bwt_g < 2500 then lowbwt=1; if bwt_g >=2500 then lowbwt=0; if sex=1 and race=1 then sexrace=1; if sex=1 and race=2 then sexrace=2; if sex=2 and race=1 then sexrace=3; if sex=2 and race=2 then sexrace=4; run; /*Univariate Statistics and Graphs*/ proc means data=owen2; title "Descriptive Statistics for All Numeric Variables"; title2 "After Fixing Missing Value Codes"; run; proc contents data=owen2; title "Contents of SAS Data Set"; run; proc format; value sexfmt 1="1:Male" 2="2:Female"; value lbwtfmt 1="1:Low" 0="0:Not Low"; value racefmt 1="1:White" 2="2:Black"; value sexrfmt 1="1:White Male" 2="2:White Female" 3="3:Black Male" 4="4:Black Female"; run; proc freq data=owen2; tables childnum sex race sexrace w_rank b_order lowbwt; format sex sexfmt. lowbwt lbwtfmt. race racefmt. sexrace sexrfmt.; title "Frequencies for Categorical Variables"; run; proc chart data=owen2; hbar sex race w_rank b_order lowbwt / discrete; title "Bar Charts for Categorical Variables"; run; /*Histograms for continuous variables*/ proc univariate data=owen2 plot; var age b_weight weight ; histogram; title "Histogram for Continuous Variables"; run; /*Bivariate Relationships of Two Categorical Variables*/ proc freq data=owen2; tables sex*childnum; title "Crosstabulation of Sex and Child Number"; run; /*Bivariate Relationships of Two Continuous Variables*/ proc plot data=owen2; plot weight * height; title "Scatter Plot of Weight vs Height"; run; proc gplot data=owen2; plot weight * height; run; /*Bivariate Relationships of Continuous vs. Categorical Variable*/ proc sort data=owen2; by sex; run; proc univariate data=owen2 plot; by sex; var weight; title "Side-by-Side Boxplot Using Proc Univariate"; run; proc boxplot data=owen2; plot weight*sex / boxstyle=schematic; title "Side-by-Side Boxplot Using Proc Boxplot"; run;