Skip to content

Instantly share code, notes, and snippets.

@rcquan rcquan/00_MacrosFormats.sas Secret
Last active Aug 29, 2015

Embed
What would you like to do?
**************************
Ryan Quan
Data Transformations
Children Center's Data
2014-06-10
**************************
This is an analysis of the effect of prenatal mercury exposure
on childhood obesity using the SAS dataset
"*********" from the Children's Center Data.
Please run this .sas program first in order to load the
necessary macros and formats used in this analysis.
***********************
FORMATS
**********************;
proc format;
value hgtertiles
0 = "First (<1.5ug/L)"
1 = "Second (1.5-3.7ug/L)"
2 = "Third (>3.7ug/L)";
value income
1 = "<10,000"
2 = "10,000 - 20,000"
3 = "20,001 - 30,000"
4 = "30,001 - 40,000"
5 = "40,001 - 50,000"
6 = "50,001 - 60,000"
7 = "60,001 - 70,000"
8 = "70,001 - 80,000"
9 = "80,001 - 90,000"
10 = ">90,000"
88,99,. = "Unknown";
value ethnicity
3 = "Dominican/Domin American"
5 = "African American";
value gender
1 = "Female"
2 = "Male";
value yesno
1 = "Yes"
2 = "No"
9,99,8,. = "Unknown";
run;
proc format;
value hgepa
0 = "low"
1 = "high";
run;
proc format;
value hgtertiles
0 = "First (<1.5ug/L)"
1 = "Second (1.5-3.7ug/L)"
2 = "Third Tertile(>3.7ug/L";
run;
proc format;
value bmi
2 = "obese"
1 = "overweight"
0 = "normal"
-1 = "thin"
-2 = "severely thin";
run;
***********************
MACROS
**********************;
/*Mean*/
%macro mean(var=);
proc means data=mercury N mean std min max nmiss;
var &var;
run;
%mend mean;
/*Freq*/
%macro freq(var=);
proc freq data=mercury;
table &var;
run;
%mend freq;
/*Tabulate*/
%macro tab(data=);
proc tabulate data = &data missing;
class newgendr A18_0 B02D_0 A17_0 A08_0 HG_CORD_tertiles;
tables newgendr A18_0 B02D_0 A17_0 A08_0 HG_CORD_tertiles, n pctn;
format newgendr gender. A18_0 ethnicity. B02D_0 yesno. A17_0 yesno. A08_0 income. HG_CORD_tertiles hgtertiles.;
run;
data mercury_cont;
set &data;
if birthwt > 0;
if A03_0 >=0;
run;
proc tabulate data = mercury_cont;
var birthwt A03_0;
tables birthwt A03_0, mean std;
run;
%mend tab;
/*Tabulate w/ BMI Categories*/
%macro tabBMI_cat(data=, BMI_cat =);
proc tabulate data = &data missing;
class newgendr A18_0 B02D_0 A17_0 A08_0 HG_CORD_tertiles &BMI_cat;
tables newgendr A18_0 B02D_0 A17_0 A08_0 HG_CORD_tertiles, &BMI_cat*(n pctn);
format newgendr gender. A18_0 ethnicity. B02D_0 yesno. A17_0 yesno. A08_0 income. HG_CORD_tertiles hgtertiles.;
run;
data mercury_cont;
set &data;
if birthwt > 0;
if A03_0 >=0;
run;
proc tabulate data = mercury_cont;
class &BMI_cat;
var birthwt A03_0;
tables birthwt A03_0, &BMI_cat*(mean std);
run;
%mend tabBMI_cat;
/*Mean + Geomean*/
%macro geomean (data=, class=);
proc means data = &data;
class &class;
var HG_CORD;
run;
proc means data = &data;
class &class;
var LOGHG_CORD;
output out = gm mean = mean_log std = std_log lclm=lci uclm=uci replace;
run;
data gm_HG_CORD;
set gm;
geomean = exp(mean_log);
std = exp(std_log);
lcgm = exp(lci);
ucgm = exp(uci);
run;
proc print data = gm_HG_CORD;
run;
%mend;
/*Regression Models*/
%macro regmod (data = , depvar =);
/* Sort to get correct reference categories*/
proc sort data = &data;
by descending HG_CORD_TERTILES A17_0 descending A18_0 descending newgendr;
run;
/* Using Tertiles of Cord Blood Mercury*/
/*Univariate*/
proc glm data = &data order = data plots = (diagnostics);
class HG_CORD_TERTILES;
model &depvar = HG_CORD_TERTILES / solution;
run;
/*Simple Multivariate*/
proc glm data = &data order = data plots = (diagnostics);
class HG_CORD_TERTILES newgendr A18_0;
model &depvar = HG_CORD_TERTILES birthwt A18_0 newgendr / solution;
format HG_CORD_TERTILES hgtertiles. newgendr gender. A18_0 ethnicity.;
run;
/*Big Multivariate*/
proc glm data = &data order = data plots = (diagnostics);
class HG_CORD_TERTILES newgendr A18_0 A17_0;
model &depvar = HG_CORD_TERTILES birthwt A18_0 A17_0 newgendr A03_0 A08_0 / solution;
format HG_CORD_TERTILES hgtertiles. A18_0 ethnicity. A17_0 yesno. newgendr gender.;
run;
/*Using Log of Cord Blood Mercury*/
/*Univariate*/
proc glm data = &data order = data plots = (diagnostics);
model &depvar = LOGHG_CORD / solution;
run;
/*Simple Multivariate*/
proc glm data = &data order = data plots = (diagnostics);
class newgendr A18_0;
model &depvar = LOGHG_CORD birthwt A18_0 newgendr / solution;
format newgendr gender. A18_0 ethnicity.;
run;
/*Big Multivariate*/
proc glm data = &data order = data plots = (diagnostics);
class newgendr A18_0 A17_0;
model &depvar = LOGHG_CORD birthwt A18_0 A17_0 newgendr A03_0 A08_0 / solution;
format A18_0 ethnicity. A17_0 yesno. newgendr gender.;
run;
%mend;
**************************
Ryan Quan
Summary Statistics
Children Center's Data
2014-06-01
**************************
This is an analysis of the effect of prenatal mercury exposure
on childhood obesity using the SAS dataset
"*******" from the Children's Center Data.
PREREQUSITE: 00_MasterProgram.sas
GOAL: Running PROC MEANS and PROC FREQ for summary statistics
of our variables of interest.
**********************
READING IN MERCURY DATA
**********************;
libname rq "&root\Data\";
data mercury;
set rq.AR_JG_2014002a;
run;
***********************
SUMMARY STATISTICS
***********************;
***********************
EXPOSURE VARIABLES
***********************;
ODS RTF FILE = "&root\Results\01_Mercury_PROCMEANS.rtf";
ODS NOPROCTITLE;
%mean(var = HG_BLOOD) /*Maternal Blood Hg*/
%mean(var = HGMFLAG) /*CDC Flag Mother Hg NEW 2005*/
%mean(var = HG_CORD) /*Cord Blood Hg*/
%mean(var = HGCFLAG) /*CDC Flag Cord Hg NEW 2005*/
%mean(var = PB_FLAG) /*Lead Flag Cord*/
/****************************
OUTCOME VARIABLES 5 Years Old
*****************************/
%mean (var = BMI60) /*Body Mass index value*/
%mean (var = BMIZ60) /*Z-score BMI for age*/
/****************************
OUTCOME VARIABLES 7 Years Old
*****************************/
%mean (var = BMI84) /*Body Mass index value*/
%mean (var = BMIZ84) /*Z-score BMI for age*/
%mean (var = bcacfatp7) /*Fat % child analyzer*/
%mean (var = bcacffm7) /*Fat-Free Mass*/
%mean (var = BCACTBW7) /*Total Body Weight*/
%mean (var = BCACIWB7) /*Whole body impedence*/
%mean (var = BCWC_C7) /*Waist circumference in cm*/
/****************************
OUTCOME VARIABLES 9 Years Old
*****************************/
%mean (var = BMI9) /*Body Mass index value*/
%mean (var = BMIZ9) /*Z-score BMI for age*/
%mean (var = bcacfatp9) /*Fat % child analyzer*/
%mean (var = bcacffm9) /*Fat-Free Mass*/
%mean (var = BCACTBW9) /*Total Body Weight*/
%mean (var = BCACIWB9) /*Whole body impedence*/
%mean (var = BCWC_C9) /*Waist circumference in cm*/
/****************************
OUTCOME VARIABLES Tanner Stage
*****************************/
%mean (var = BMI_T) /*Body Mass index value*/
%mean (var = BMIZ_T) /*Z-score BMI for age*/
%mean (var = TANWC1) /*Waist Circumference*/
%mean (var = TANWC2)
%mean (Var = TANWC3);
ODS RTF close;
***********************
SUMMARY STATISTICS
***********************
Running PROC FREQ for summary
statistics of our variables of interest.
***********************
EXPOSURE VARIABLES
***********************;
ODS RTF FILE = "&root\Results\01_Mercury_PROCFREQ.rtf";
ODS NOPROCTITLE;
%freq(var = HG_BLOOD) /*Maternal Blood Hg*/
%freq(var = HGMFLAG) /*CDC Flag Mother Hg NEW 2005*/
%freq(var = HG_CORD) /*Cord Blood Hg*/
%freq(var = HGCFLAG) /*CDC Flag Cord Hg NEW 2005*/
%freq(var = PB_FLAG) /*Lead Flag Cord*/
/****************************
OUTCOME VARIABLES 5 Years Old
*****************************/
%freq (var = BMI60) /*Body Mass index value*/
%freq (var = BMIZ60) /*Z-score BMI for age*/
/****************************
OUTCOME VARIABLES 7 Years Old
*****************************/
%freq (var = BMI84) /*Body Mass index value*/
%freq (var = BMIZ84) /*Z-score BMI for age*/
%freq (var = bcacfatp7) /*Fat % child analyzer*/
%freq (var = bcacffm7) /*Fat-Free Mass*/
%freq (var = BCACTBW7) /*Total Body Weight*/
%freq (var = BCACIWB7) /*Whole body impedence*/
%freq (var = BCWC_C7) /*Waist circumference in cm*/
/****************************
OUTCOME VARIABLES 9 Years Old
*****************************/
%freq (var = BMI9) /*Body Mass index value*/
%freq (var = BMIZ9) /*Z-score BMI for age*/
%freq (var = bcacfatp9) /*Fat % child analyzer*/
%freq (var = bcacffm9) /*Fat-Free Mass*/
%freq (var = BCACTBW9) /*Total Body Weight*/
%freq (var = BCACIWB9) /*Whole body impedence*/
%freq (var = BCWC_C9) /*Waist circumference in cm*/
/****************************
OUTCOME VARIABLES Tanner Stage
*****************************/
%freq (var = BMI_T) /*Body Mass index value*/
%freq (var = BMIZ_T) /*Z-score BMI for age*/
%freq (var = TANWC1) /*Waist Circumference*/
%freq (var = TANWC2)
%freq (Var = TANWC3);
ODS RTF close;
**************************
Ryan Quan
Dropping Observations
Children Center"s Data
2014-06-09
**************************
This is an analysis of the effect of prenatal mercury exposure
on childhood obesity using the SAS dataset
"AR_JG_2014002a.sas7bdat" from the Children"s Center Data.
PREREQUSITE: 00_MacrosFormats.sas
GOAL: To drop observations from our analysis that do not meet
the following inclusionary criteria:
*poor sample quality
*insufficient sample amount
*below limit of detection
*clotted samples (from both lead and mercury flags)
*missing measurement for cord blood mercury
**********************
READING IN MERCURY DATA
**********************;
libname rq "&root\Data";
data mercury;
set rq.AR_JG_2014002a;
run;
*****************************
Assigning and Dropping Variables
with Exclusionary Criteria
*****************************;
ODS RTF FILE = "&root\Results\02_Mercury_MISSING.rtf";
ODS NOPROCTITLE;
%mean(var = HG_CORD) /*N=503*/
/* HG_CORD - Cord blood mercury
-9.00 Missing Sample
-8.00 Unsatisfactory Sample
-7.00 QNS
.07 < LOD (0.14)
.10 < LOD (0.2) */
data mercury;
set mercury;
if HG_CORD = -9.0 then delete;
run;
/*19 observations dropped*/
data mercury;
set mercury;
if HG_CORD = -8.0 then delete;
run;
/*1 observations dropped*/
data mercury;
set mercury;
if HG_CORD = -7.0 then delete;
run;
/*0 observation dropped*/
data mercury;
set mercury;
if HG_CORD < 0.07 & HG_CORD > . then delete;
run;
/* 0 observations dropped*/
/* note that if we used a LOD <.10, we would
have dropped 1 observation that fell in between
0.07 and 0.10. */
data mercury;
set mercury;
if HG_CORD = . then delete;
run;
/* 224 observations dropped*/
%mean(var = HG_CORD); /*N = 483*/
/* HGCFLAG - CDC flag cord Hg NEW 2005
5 clotted
6 small clots
7 results repeated & confirmed
9 sample fine */
data mercury;
set mercury;
if HGCFLAG =5 then delete;
run;
/*N=6; 0 observations dropped*/
data mercury;
set mercury;
if HGCFLAG =6 then delete;
run;
/*N=13; 0 observations dropped*/
%mean(var = HG_CORD); /*N = 483*/
*PB_FLAG
1 < LOD (0.6 or 0.3)
2 unsatisfactory specimen
3 QNS
4 no flag
5 clotted
9 missing;
proc freq data = mercury; /*no overlap in flags*/
tables PB_FLAG*HGCFLAG/missing;
run;
data mercury;
set mercury;
if PB_FLAG = 2 then delete;
run;
/*N=5; 2 observations dropped*/
data mercury;
set mercury;
if PB_FLAG = 5 then delete;
run;
/*N=34; 25 observations dropped*/
%mean(var = HG_CORD); /*N = 456*/
*********************************
Uncomment block below to exclude mothers
with invalid blood samples
*********************************;
/*
*HG_BLOOD - Mom blood mercury
-9.00 Missing Sample
-8.00 Unsatisfactory Sample
-7.00 QNS
.10 < LOD (0.2);
data mercury;
set mercury;
if HG_BLOOD =-9 then delete;
if HG_BLOOD =-8 then delete;
if HG_BLOOD =-7 then delete;
if HG_BLOOD >=0 & HG_BLOOD <.10 then delete;
run;
%mean(var = HG_CORD) *N = 454;
*HGMFLAG - CDC flag mother Hg NEW 2005
5 clotted
6 small clots
7 results repeated & confirmed
9 sample fine;
data mercury;
set mercury;
if HGMFLAG =5 then delete;
if HGMFLAG =6 then delete;
run;
%mean(var = HG_CORD) *N = 454;
*/
******************************
SUMMARY VISUALIZATIONS
******************************;
proc univariate data = mercury;
var HG_CORD;
histogram;
run;
proc sgplot data = mercury;
hbox HG_CORD;
run;
/*Save formatted dataset to library*/
data rq.mercury_nomissing;
set mercury;
run;
ODS RTF close;
**************************
Ryan Quan
Data Transformations
Children Center's Data
2014-06-10
**************************
This is an analysis of the effect of prenatal mercury exposure
on childhood obesity using the SAS dataset
"********" from the Children's Center Data.
PREREQUISITE: 00_MacrosFormats.sas
GOAL: To create new categorical/dichotomous
variables and log-transform the dependent variable
to create a dataset that will be ready for analysis.
We will also split the dataset by age, retaining only observations
with anthropometric measures (BMI Z-scores).
**********************
READING IN MERCURY DATA
**********************;
libname rq "&root\Data";
data mercury;
set rq.mercury_nomissing;
run;
*************************
CREATING CATEGORICAL VARIABLES
*************************;
ODS RTF FILE = "&root\Results\03_Mercury_CategoricalVars.rtf";
ODS NOPROCTITLE;
data mercury; /*EPA Cut-offs for young children*/
set mercury;
if HG_CORD < 5.8 then HG_CORD_EPA = 0;
if HG_CORD >= 5.8 then HG_CORD_EPA = 1;
format HG_CORD_EPA hgepa.;
run;
%mean (var = HG_CORD_EPA);
%freq (var = HG_CORD_EPA);
proc univariate data = mercury;
var HG_CORD;
output out=HG_CORD_tertiles pctlpts=33 77 pctlpre=HG_CORDP;
run;
proc print data = HG_CORD_tertiles;
run;
data mercury;
set mercury;
if HG_CORD >= 0 & HG_CORD <1.5 then HG_CORD_tertiles = 0;
if HG_CORD >= 1.5 & HG_CORD <3.7 then HG_CORD_tertiles = 1;
if HG_CORD >= 3.7 then HG_CORD_tertiles = 2;
format HG_CORD_tertiles hgtertiles.;
run;
%mean (var = HG_CORD_tertiles);
%freq (var = HG_CORD_tertiles);
data mercury;
set mercury;
array BMI{3} BMIZ60 BMIZ84 BMIZ9;
array BMI_cat{3} BMIZ60_cat BMIZ84_cat BMIZ9_cat;
do i = 1 to 3;
BMI_cat{i} = .;
if BMI{i} >= 2 then BMI_cat{i} = 2;
if BMI{i} < 2 & BMI{i} >= 1 then BMI_cat{i} = 1;
if BMI{i} < 1 & BMI{i} > -1 then BMI_cat{i} = 0;
if BMI{i} <= -1 & BMI{i} > -2 then BMI_cat{i} = -1;
if BMI{i} <= -2 & (BMI{i} > .) then BMI_cat{i} = -2;
end;
run;
data mercury;
set mercury;
format BMIZ60_cat bmi.;
format BMIZ84_cat bmi.;
format BMIZ9_cat bmi.;
run;
%mean (var = BMIZ60_cat BMIZ84_cat BMIZ9_cat);
%freq (var = BMIZ60_cat BMIZ84_cat BMIZ9_cat);
ODS RTF close;
*************************************************
LOG TRANSFORMATION OF HG_CORD
*************************************************;
data mercury;
set mercury;
LOGHG_CORD = LOG(HG_CORD);
run;
*************************************************
Saving completed / subsetted datasets to library
************************************************;
/*N = 456*/
data rq.mercury_complete;
set mercury;
run;
/*N = 321*/
data rq.mercury_05;
set mercury;
if BMIZ60 > .;
run;
/*N = 326*/
data rq.mercury_07;
set mercury;
if BMIZ84 > .;
run;
/*N = 176*/
data rq.mercury_09;
set mercury;
if BMIZ9 > .;
run;
**************************
Ryan Quan
Table 1
Children Center's Data
2014-06-10
**************************
This is an analysis of the effect of prenatal mercury exposure
on childhood obesity using the SAS dataset
"********" from the Children's Center Data.
PREREQUISITES: 00_MacroFormats.sas, 03_DataTransformations.sas
GOAL: To find out the origin of each child from each follow-up
group. This is done to answer the following types of questions:
* how many observations were followed up at ages 5, 7, and 9?
* how many observations were followed up at ages 7, but not ages 5?
* how many observations were followed up at ages 5 and 9, but not 7?
**********************
READING IN MERCURY DATA
**********************;
libname rq "&root\Data";
data mercury;
set rq.mercury_complete;
run;
data mercury_05;
set rq.mercury_05;
run;
data mercury_07;
set rq.mercury_07;
run;
data mercury_09;
set rq.mercury_09;
run;
ODS RTF FILE = "&root\Results\04_Mercury_Exclusion.rtf";
title "Follow-Up Numbers for Exclusionary Chart";
/*Children followed up at age 7 years*/
proc means data = mercury_07;
var bmiz60;
title "7Y followed up from 5Y";
run;
data mercury_00to07;
set mercury_07;
if bmiz60 =.;
run;
proc means data = mercury_00to07;
var sid;
title "7Y followed up First Time";
run;
/*Children followed up at age 9 Years */
proc means data = mercury_09;
var bmiz84;
title "9Y followed up from 7Y";
run;
data mercury_05to09;
set mercury_09;
if bmiz84 =.;
run;
proc means data = mercury_05to09;
var bmiz60;
title "9Y followed up from 5Y";
run;
data mercury_00to09;
set mercury_09;
if bmiz84 =. & bmiz60 =.;
run;
proc means data = mercury_00to09;
var sid;
title "9Y followed up First Time";
run;
ODS RTF close;
**************************
Ryan Quan
Table 1 - BMI Descriptives
Children Center's Data
2014-06-16
**************************
This is an analysis of the effect of prenatal mercury exposure
on childhood obesity using the SAS dataset
"*********" from the Children's Center Data.
PREREQUISITE: 00_MacrosFormats.sas, 03_DataTransformations
GOAL: To tabulate the counts/pct for categorical
variables and mean/std for continuous variables for the total
cohort and children with anthropometric measures at (5, 7, 9).
**********************
READING IN MERCURY DATA
**********************;
libname rq "&root\Data";
data mercury;
set rq.mercury_complete;
run;
data mercury_05;
set rq.mercury_05;
run;
data mercury_07;
set rq.mercury_07;
run;
data mercury_09;
set rq.mercury_09;
run;
***********************
MACROS
**********************;
ODS RTF FILE = "&root\Results\05_Mercury_Table1_Complete.rtf";
title "Table 1 - Total Cohort";
proc means data = mercury;
var bmiz60 bmiz84 bmiz9;
run;
%tab(data = mercury);
/*Annual Household Income at Child's Age*/
proc tabulate data = mercury;
class A08_60 A08_84;
tables A08_60 A08_84, n pctn;
format A08_60 income. A08_84 income.;
title "Annual Household Income at Child's Age";
run;
ODS RTF close;
ODS RTF FILE = "&root\Results\05_Mercury_Table1_05.rtf";
title "Table 1 - Child at Age 5";
%tab(data = mercury_05);
/*Age 5 does NOT have measurements other than BMI*/
proc means data = mercury_05;
var HG_CORD bmi60 bmiz60;
run;
proc univariate data = mercury_05;
var HG_CORD bmi60 bmiz60;
histogram;
qqplot;
run;
ODS RTF close;
ODS RTF FILE = "&root\Results\05_Mercury_Table1_07.rtf";
title "Table 1 - Child at Age 7";
%tab(data = mercury_07)
proc means data = mercury_07;
var HG_CORD bmi84 bmiz84 bcacfatp7 bcacfatm7 bcacffm7 bcactbw7 bcaciwb7;
run;
/*missing value in bcwc_c7*/
data mercury_07i;
set mercury_07;
if bcwc_c7 > 0;
run;
proc means data = mercury_07i;
var bcwc_c7;
run;
proc univariate data = mercury_07;
var HG_CORD bcacfatp7 bcacfatm7 bcacffm7 bcactbw7 bcaciwb7;
histogram;
qqplot;
run;
proc univariate data = mercury_07i;
var bcwc_c7;
histogram;
qqplot;
run;
ODS RTF close;
ODS RTF FILE = "&root\Results\05_Mercury_Table1_09.rtf";
title "Table 1 - Child at Age 9";
%tab(data = mercury_09);
proc means data = mercury_09;
var HG_CORD bcacfatp9 bcacfatm9 bcacffm9 bcactbw9 bcaciwb9;
run;
/*missing value in bcwc_c9*/
data mercury_09i;
set mercury_09;
if bcwc_c9 > 0;
run;
proc means data = mercury_09i;
var bcwc_c9;
run;
proc univariate data = mercury_09;
var HG_CORD bcacfatp9 bcacfatm9 bcacffm9 bcactbw9 bcaciwb9;
histogram;
qqplot;
run;
proc univariate data = mercury_09i;
var bcwc_c9;
histogram;
qqplot;
run;
ODS RTF close;
ODS RTF FILE = "&root\Results\05_Mercury_Table1_BMIcat.rtf";
title "Descriptives by BMI Categories";
%tabBMI_cat(data = mercury_05, BMI_cat = BMIZ60_cat);
%tabBMI_cat(data = mercury_07, BMI_cat = BMIZ84_cat);
%tabBMI_cat(data = mercury_09, BMI_cat = BMIZ9_cat);
ODS RTF close;
**************************
Ryan Quan
Table 2 - Geomeans
Children Center's Data
2014-06-27
**************************
This is an analysis of the effect of prenatal mercury exposure
on childhood obesity using the SAS dataset
"*********" from the Children's Center Data.
PREREQUISITE: 00_MacrosFormats.sas, 03_DataTransformations.sas
GOAL: To report the arithmetic and geometric means for cord
blood mercury levels from the total cohort and follow-up groups.
We also stratify by gender, ethnicity, and public assistance.
**********************
READING IN MERCURY DATA
**********************;
libname rq "&root\Data";
data mercury;
set rq.mercury_complete;
run;
data mercury_05;
set rq.mercury_05;
run;
data mercury_07;
set rq.mercury_07;
run;
data mercury_09;
set rq.mercury_09;
run;
ODS RTF FILE = "&root\Results\06_Mercury_Geomeans.rtf";
title "Geometric Means for HG_CORD";
/*Total Cohort*/
%geomean(data = mercury);
%geomean(data = mercury, class = newgendr); /*gender*/
%geomean(data = mercury, class = A18_0); /*ethnicity*/
%geomean(data = mercury, class = A17_0); /*public assistance*/
/*Age 5*/
%geomean(data = mercury_05)
%geomean(data = mercury_05, class = newgendr); /*gender*/
%geomean(data = mercury_05, class = A18_0); /*ethnicity*/
%geomean(data = mercury_05, class = A17_0); /*public assistance*/
%geomean(data = mercury_05, class = BMIZ60_cat);/*BMI categorires*/
/*Age 7*/
%geomean(data = mercury_07)
%geomean(data = mercury_07, class = newgendr); /*gender*/
%geomean(data = mercury_07, class = A18_0); /*ethnicity*/
%geomean(data = mercury_07, class = A17_0); /*public assistance*/
%geomean(data = mercury_07, class = BMIZ84_cat);/*BMI categorires*/
/*Age 9*/
%geomean(data = mercury_09)
%geomean(data = mercury_09, class = newgendr); /*gender*/
%geomean(data = mercury_09, class = A18_0); /*ethnicity*/
%geomean(data = mercury_09, class = A17_0); /*public assistance*/
%geomean(data = mercury_09, class = BMIZ9_cat); /*BMI categorires*/
ODS RTF close;
**************************
Ryan Quan
Table 1
Children Center's Data
2014-06-29
**************************
This is an analysis of the effect of prenatal mercury exposure
on childhood obesity using the SAS dataset
"***********" from the Children's Center Data.
PREREQUISITE: 00_MacrosFormats.sas, 03_DataTransformations.sas
GOAL: To construct the following linear models for follow-up groups
ages 5, 7, and 9:
* CRUDE: BMI ~ HG_CORD
* SIMPLE: BMI ~ HG_CORD + BIRTHWEIGHT + ETHNICITY + GENDER
* BIG: BMI ~ HG_CORD + BIRTHWEIGHT + ETHNICITY + GENDER
+ EDUCATION + PUBLIC ASSISTANCE + INCOME
We construct one set of models using the log-transformed HG_CORD and
another using HG_CORD_TERTILES.
We also provide a correlation matrix for mom blood mercury and
cord blood mercury and for cord blood lead and cord blood mercury.
**********************
READING IN MERCURY DATA
**********************;
libname rq "&root\Data";
data mercury;
set rq.mercury_complete;
run;
data mercury_05;
set rq.mercury_05;
run;
data mercury_07;
set rq.mercury_07;
run;
data mercury_09;
set rq.mercury_09;
run;
ODS RTF FILE = "&root\Results\07_Mercury_HGBloodCorr.rtf";
title "Correlation between Mother's Blood Mercury and Cord Blood Mercury";
data mercury;
set mercury;
if HG_BLOOD =-9 then delete;
if HG_BLOOD =-8 then delete;
if HG_BLOOD =-7 then delete;
if HG_BLOOD >=0 & HG_BLOOD <.10 then delete;
run;
proc corr data = mercury;
var HG_BLOOD HG_CORD;
run;
ODS RTF close;
ODS RTF FILE = "&root\Results\07_Mercury_HGLEADCorr.rtf";
title "Correlation between Cord Blood Mercury & Cord Blood Lead";
proc corr data = mercury;
var HG_CORD LEAD BMIZ60 BMIZ84 BMIZ9;
run;
ODS RTF close;
ODS RTF FILE = "&root\Results\07_LinearModel_Age5.rtf";
title "Linear Models for Age 5 Follow-Ups";
%regmod (data = mercury_05, depvar = BMIZ60);
ODS RTF close;
ODS RTF FILE = "&root\Results\07_LinearModel_Age7.rtf";
title "Linear Models for Age 7 Follow-Ups";
%regmod (data = mercury_07, depvar = BMIZ84);
ODS RTF close;
ODS RTF FILE = "&root\Results\07_LinearModel_Age9.rtf";
title "Linear Models for Age 9 Follow-Ups";
%regmod (data = mercury_09, depvar = BMIZ9);
ODS RTF close;
*********************************************************
*********************************************************
PROGRAM NAME: MasterProgram.sas
DATE CREATED: June 29, 2014
AUTHOR: Ryan Quan
PURPOSE: Runs the programs for Mercury/Obesity Analysis
INPUTS: 00_MacrosFormats.sas
01_SummarySatistics.sas
02_DroppingObservations.sas
03_DataTransformations.sas
04_CohortDescriptives.sas
05_Table1_BMI.sas
06_Table2_Geomeans.sas
07_LinearModels.sas
OUTPUTS: See individual SAS programs for outputs
*********************************************************
*********************************************************
Before we begin, please set your working directory by changing
the filepath below as defined by the macro "root":
*********************************************************
SET WORKING DIRECTORY
*********************************************************;
%let root= \\psf\Dropbox\Mercury_Obesity;
*********************************************************
DESCRIPTION
*********************************************************
To run this program, please create the following folders in
your working directory:
* Data
* Results
* Programs
For this program to run, the .sas programs listed above in the "INPUTS"
section must be placed in your "Programs" folder. The dataset entitled
"AR_JG_2014002a.sas7bdat" must also be placed in your "Data" folder.
All dataset outputs will be created in the "Data" folder.
All ODS outputs will be be created in the "Results" folder.
*********************************************************
PROGRAMS
*********************************************************;
%include "&root\Programs\00_MacrosFormats.sas";
%include "&root\Programs\01_SummarySatistics.sas";
%include "&root\Programs\02_DroppingObservations.sas";
%include "&root\Programs\03_DataTransformations.sas";
%include "&root\Programs\04_CohortDescriptives.sas";
%include "&root\Programs\05_Table1_BMI.sas";
%include "&root\Programs\06_Table2_Geomeans.sas";
%include "&root\Programs\07_LinearModels.sas";
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.