*Makes simulated data; dm 'output' clear; dm 'log' clear; %let outputroot = C:\blah\blah; *Directory where the graphical output will go; options papersize="letter" orientation=landscape; ods noresults; goptions reset=all; libname mylib "&outputroot"; %let seed1 = 47; %let seed2 = 48; %let seed3 = 49; %let seed4 = 147; %let seed5 = 148; %let seed6 = 149; %let mu1 = 120; %let sd1 = 10; %let mu2 = 120; %let sd2 = 20; %let mu3 = 120; %let sd3 = %sysevalf( &sd1 / 4 ); %let mu4 = 110; %let sd4 = &sd1; %let mu5 = 130; %let sd5 = &sd1; %let mu6 = 150; %let sd6 = &sd1; %macro getData( n ); data data&n; format bp 4. group 2.; do i=1 to 50; bp = round( &&mu&n + normal( &&seed&n )*&&sd&n, 1 ); group = &n; output; end; drop i; run; %mend getData; title; %getData( 1 ) %getData( 2 ) %getData( 3 ) %getData( 4 ) %getData( 5 ) %getData( 6 ); *First Scatterplot; ods pdf file="&outputroot\output8.pdf" bookmarklist=OFF; proc gplot data=data1; plot group*bp; run; ods pdf close; *Make nicer looking; proc freq data=data1 noprint; tables group*bp / out=data1stats (keep = group bp count ); run; goptions ftitle='Times/bold' ftext='Times'; axis1 label=( 'mmHg' ) order=( 90 to 150 by 10 ) minor=( number=4 ) value=( height=1.2 ); axis2 label=( '' ) value=( height=1.2 ); title 'Systolic Blood Pressure'; ods pdf file="&outputroot\output9a.pdf" bookmarklist=OFF; proc gplot data=data1stats; plot group*bp=count / haxis=axis1 vaxis=axis2; run; ods pdf close; *Bubble Plot; ods pdf file="&outputroot\output9b.pdf" bookmarklist=OFF; proc gplot data=data1stats; bubble group*bp=count / haxis=axis1 vaxis=axis2 bcolor=red; run; ods pdf close; *Histogram; goptions reset=all; ods pdf file="&outputroot\output1.pdf" bookmarklist=OFF; proc gchart data=data1; vbar bp; run; ods pdf close; * Make output more readable; goptions ftitle='Times/bold' ftext='Times'; axis1 label=( 'Interval Midpoint (mmHg)' height=1.2 ) offset=( 4, 4 ) value=( height=1.2 ); axis2 label=( angle=90 height=1.2 'Frequency' ) order=( 0 to 20 by 5 ) minor=( number=4 ) value=( height=1.2 ); title 'Systolic Blood Pressure'; ods pdf file="&outputroot\output2.pdf" bookmarklist=OFF; proc gchart data=data1; vbar bp / maxis=axis1 raxis=axis2 width=4 space=2; run; ods pdf close; * Make output even more readable; axis1 label=( 'mmHg' ) value=( height=1.2 '92 - 100' '100 - 108' '108 - 116' '116 - 124' '124 - 132' '132 - 140' '140 - 148' ) offset=( 4, 4 ); *axis2 label=( angle=90 height=1.2 'Frequency' ) order=( 0 to 20 by 5 ) minor=( number=4 ) value=( height=1.2 ); ods pdf file="&outputroot\output3.pdf" bookmarklist=OFF; proc gchart data=data1; vbar bp / maxis=axis1 raxis=axis2 width=4 space=2 midpoints = 96 to 144 by 8; run; ods pdf close; *Just enough midpoints; axis1 label=( 'Interval Midpoint (mmHg)' height=1.2 ) value=( height=1.2 ); axis2 label=( angle=90 'Frequency' height=1.2 ) value=( height=1.2 ); title 'Systolic Blood Pressure, 5 Intervals'; ods pdf file="&outputroot\output4.pdf" bookmarklist=OFF; proc gchart data=data1; vbar bp / maxis=axis1 raxis=axis2 levels = 5; run; ods pdf close; *Not enough midpoints; title 'Systolic Blood Pressure, 2 Intervals'; ods pdf file="&outputroot\output5.pdf" bookmarklist=OFF; proc gchart data=data1; vbar bp / maxis=axis1 raxis=axis2 levels = 2; run; ods pdf close; *Too many midpoints; title 'Systolic Blood Pressure, 15 Intervals'; ods pdf file="&outputroot\output6.pdf" bookmarklist=OFF; proc gchart data=data1; vbar bp / maxis=axis1 raxis=axis2 levels = 15; run; ods pdf close; goptions reset=all; goptions ftitle='Times/bold' ftext='Times'; symbol1 c=red; axis1 label=( angle=90 'mmHg' height=1.2 ) order=( 90 to 150 by 10 ) minor=( number=3 ) value=( height=1.2 ); axis2 label=( '' ) value=( height=1.2 ); title 'Systolic Blood Pressure'; ods pdf file="&outputroot\output10.pdf" bookmarklist=OFF; proc gplot data=data1stats; bubble bp*group=count / vaxis=axis1 haxis=axis2 bcolor=red; run; ods pdf close; *Box Plots; axis1 label=( 'mmHg' height=1.2 ) order=( 90 to 150 by 10 ) minor=( number=3 ) value=( height=1.2 ); symbol1; ods pdf file="&outputroot\output11.pdf" bookmarklist=OFF; proc boxplot data=data1; plot bp*group / vaxis=axis1 haxis=axis2; run; ods pdf close; proc univariate noprint data=data1; var bp; by group; output min=min mean=mean q1=q1 median=med q3=q3 max=max out=stats; run; data anno1; set stats; format function $8. text $50.; retain when 'a'; function = 'label'; text = '{'||trim( left( put( min, 5. ) ) )||', '|| trim( left( put( q1, 5. ) ) )||', '|| trim( left( put( med, 5. ) ) )||', '|| trim( left( put( q3, 5. ) ) )||', '|| trim( left( put( max, 5. ) ) )||'}'; position = '2'; xsys = '2'; ysys = '3'; x = 1; y = 85; size = 1.1; output; run; ods pdf file="&outputroot\output12.pdf" bookmarklist=OFF; proc boxplot data=data1; plot bp*group / vaxis=axis1 haxis=axis2 annotate=anno1; run; ods pdf close; data data2a; set data2; if _N_ >= 40 then bp = 0; run; data data123; set data1 data2a data3; run; proc univariate data=data123 noprint; var bp; by group; output min=min mean=mean q1=q1 median=med q3=q3 max = max out=stats; run; data anno123; set stats; format function $8. text $50.; retain when 'a'; function = 'label'; text = '{'||trim( left( put( min, 5. ) ) )||', '||trim( left( put( q1, 5. ) ) )||', '|| trim( left( put( med, 5. ) ) )||', '||trim( left( put( q3, 5. ) ) )||', '|| trim( left( put( max, 5. ) ) )||'}'; position = '2'; xsys = '2'; ysys = '3'; x = group; y = 85; size = 1.1; output; run; axis1 label=( 'mmHg' ) minor=( number=4 ) value=( height=1.2 ); axis2 label=( '' ) order=( 1 to 3 by 1 ) value=( height=1.2 'Group A' 'Group B' 'Group C' ) minor=none; ods pdf file="&outputroot\output13.pdf" bookmarklist=OFF; proc boxplot data=data123; plot bp*group / vaxis=axis1 haxis=axis2 annotate=anno123; run; ods pdf close; data data123; set data1 data2 data3; run; proc univariate data=data123 noprint; var bp; by group; output min=min mean=mean q1=q1 median=med q3=q3 max = max out=stats; run; data anno123; set stats; format function $8. text $50.; retain when 'a'; function = 'label'; text = '{'||trim( left( put( min, 5. ) ) )||', '||trim( left( put( q1, 5. ) ) )||', '|| trim( left( put( med, 5. ) ) )||', '||trim( left( put( q3, 5. ) ) )||', '|| trim( left( put( max, 5. ) ) )||'}'; position = '2'; xsys = '2'; ysys = '3'; x = group; y = 85; size = 1.1; output; run; title 'Systolic Blood Pressure (Data Error Removed)'; ods pdf file="&outputroot\output14.pdf" bookmarklist=OFF; proc boxplot data=data123; plot bp*group / vaxis=axis1 haxis=axis2 annotate=anno123; run; quit; ods pdf close; data data5a; set data5; if _N_ = 1 then bp = 190; else if _N_ = 2 then bp = 188; else if _N_ = 3 then bp = 176; else if _N_ = 4 then bp = 186; else if _N_ = 5 then bp = 185; else if _N_ = 6 then bp = 192; run; data data456; set data4 data5 data6; run; data data456a; set data4 data5a data6; run; proc univariate data=data456a noprint; var bp; by group; output min=min mean=mean q1=q1 median=med q3=q3 max = max out=stats; run; data anno456a; set stats; format function $8. text $50.; retain when 'a'; function = 'label'; text = '{'||trim( left( put( min, 5. ) ) )||', '||trim( left( put( q1, 5. ) ) )||', '|| trim( left( put( med, 5. ) ) )||', '||trim( left( put( q3, 5. ) ) )||', '|| trim( left( put( max, 5. ) ) )||'}'; position = '2'; xsys = '2'; ysys = '3'; x = group; y = 85; size = 1.1; output; run; proc univariate data=data456 noprint; var bp; by group; output min=min mean=mean q1=q1 median=med q3=q3 max = max out=stats; run; data anno456; set stats; format function $8. text $50.; retain when 'a'; function = 'label'; text = '{'||trim( left( put( min, 5. ) ) )||', '||trim( left( put( q1, 5. ) ) )||', '|| trim( left( put( med, 5. ) ) )||', '||trim( left( put( q3, 5. ) ) )||', '|| trim( left( put( max, 5. ) ) )||'}'; position = '2'; xsys = '2'; ysys = '3'; x = group; y = 85; size = 1.1; output; run; axis1 label=( 'mmHg' ) minor=( number=4 ) value=( height=1.2 ); axis2 label=( '' ) order=( 4 to 6 by 1 ) value=( height=1.2 'Group D' 'Group E' 'Group F' ) minor=none; title 'Systolic Blood Pressure'; ods pdf file="&outputroot\output15a.pdf" bookmarklist=OFF; proc boxplot data=data456a; plot bp*group / vaxis=axis1 haxis=axis2 annotate=anno456a; run; ods pdf close; ods pdf file="&outputroot\output15b.pdf" bookmarklist=OFF; proc boxplot data=data456a; plot bp*group / vaxis=axis1 haxis=axis2 annotate=anno456a boxstyle=schematic; run; ods pdf close; title 'Systolic Blood Pressure (Outliers Removed)'; ods pdf file="&outputroot\output16.pdf" bookmarklist=OFF; proc boxplot data=data456; plot bp*group / vaxis=axis1 haxis=axis2 annotate=anno456; run; quit; ods pdf close; ods listing; proc univariate data=data1; var bp; run; ods listing close;