Sure. Here's the code.
%macro plotMedian(title = , test = , yAxisValues = , Units = );
title font = 'Times New Roman' height = 11pt bold &title ' (' &units ')';
proc sgplot data = Section_8_30_YForSampleSizeAdded (where = (strip(upCase(test)) = strip(upCase(&test))));
band x = Window_Label lower = P05 upper = P10 / name = 'P05_P10' transparency = 0.8 fillAttrs = (color = cx79AFE7) legendLabel = '5th-95th Percentiles';
band x = Window_Label lower = P10 upper = Q1 / name = 'P10_Q1' transparency = 0.5 fillAttrs = (color = cx79AFE7) legendLabel = '10th-90th Percentiles';
band x = Window_Label lower = Q1 upper = Q3 / name = 'Q1_Q3' transparency = 0.5 fillAttrs = (color = cxFFCFA4) legendlabel = '25th-75th Percentiles';
band x = Window_Label lower = Q3 upper = P90 / name = 'Q3_P90' transparency = 0.5 fillAttrs = (color = cx79AFE7);
band x = Window_Label lower = P90 upper = P95 / name = 'P90_P95' transparency = 0.8 fillAttrs = (color = cx79AFE7);
series x = Window_Label y = Mean / name = 'Mean' lineAttrs = (pattern = dash color = purple) legendLabel = 'Mean';
series x = Window_Label y = Median / name = 'Median' lineAttrs = (pattern = solid color = blue) legendLabel = 'Median';
scatter x = Window_Label y = y / markerChar = n markerCharAttrs = (family = 'Times New Roman' size = 10pt);
yaxis offSetMin = 0.045 offSetMax = 0.00 grid label = &Units labelAttrs = (family = 'Times New Roman' size = 10pt weight = bold) values = &yAxisValues /*valuesFormat = yaxis.*/;
xaxis offSetMin = 0.03 offSetMax = 0.03 grid display = (noLabel) valueAttrs = (family = 'Times New Roman' size = 10pt ) fitPolicy = rotate
values = ('Jul 2002 – Dec 2003' 'Jul 2003 – Dec 2004' 'Jul 2004 – Dec 2005' 'Jul 2005 – Dec 2006'
'Jul 2006 – Dec 2007' 'Jul 2007 – Dec 2008' 'Jul 2008 – Dec 2009' 'Jul 2009 – Dec 2010'
'Jul 2010 – Dec 2011' 'Jul 2011 – Dec 2012' 'Jul 2012 – Dec 2013' 'Jul 2013 – Dec 2014'
'Jul 2014 – Dec 2015' 'Jul 2015 – Dec 2016' 'Jul 2016 – Dec 2017' 'Jul 2017 – Dec 2018'
'Jul 2018 – Dec 2019'); * These must be listed, because HDL and LDL have no results before 2011. *;
keylegend 'Median' 'Mean' 'Q1_Q3' 'P10_Q1' 'P05_P10' / position = bottom valueAttrs = (family = 'Times New Roman' size = 10pt);
format n comma.;
run;
title;
%mEnd plotMedian;
ods rtf file = "&outFolder\8. Clinical Chemistry\Clinical Chemistry Lab Plots Median with Percentiles and Mean.doc" startPage = no image_dpi = 600;
ods escapeChar = '`';
%plotMedian(title = 'Alanine aminotransferase (ALT)' , test = 'ALT' , yAxisValues = (0 to 80 by 5 ), Units = 'U/L' );
%plotMedian(title = 'Aspartate aminotransferase (AST)', test = 'AST' , yAxisValues = (0 to 80 by 5 ), Units = 'U/L' );
%plotMedian(title = 'Cholesterol: Total' , test = 'Cholesterol' , yAxisValues = (0 to 300 by 20 ), Units = 'mg/dL' );
%plotMedian(title = 'Cholesterol: HDL' , test = 'HDL cholesterol', yAxisValues = (0 to 300 by 20 ), Units = 'mg/dL' );
%plotMedian(title = 'Cholesterol: LDL' , test = 'LDL cholesterol', yAxisValues = (0 to 300 by 20 ), Units = 'mg/dL' );
%plotMedian(title = 'Creatinine' , test = 'Creatinine' , yAxisValues = (0 to 2 by 0.2), Units = 'mg/dL' );
%plotMedian(title = 'Eosinophils, %' , test = 'Eosinophil %' , yAxisValues = (0 to 8 by 1 ), Units = '%' );
%plotMedian(title = 'Glucose' , test = 'Glucose' , yAxisValues = (0 to 200 by 20 ), Units = 'mg/dL' );
%plotMedian(title = 'Hemoglobin' , test = 'Hemoglobin' , yAxisValues = (0 to 20 by 2 ), Units = 'g/dL' );
%plotMedian(title = 'White Blood Cell (WBC) Count' , test = 'WBC Count' , yAxisValues = (0 to 12 by 1 ), Units = '·10^3/µL');
ods rtf close;
... View more