Presentation is loading. Please wait.

Presentation is loading. Please wait.

Introduction to Graphing in SAS

Similar presentations


Presentation on theme: "Introduction to Graphing in SAS"— Presentation transcript:

1 Introduction to Graphing in SAS
Greg Grandits, Division of Biostatistics March 6, 2017

2 Treatment of Mild Hypertension Study (TOMHS)
Clinical Trial of persons with “mild” hypertension Four clinical centers in U.S. 902 participants Six treatment groups (5 classes of BP meds) Diuretic Beta Blocker Calcium Channel Blocker Alpha Blocker ACE inhibitor Placebo All participants intervened to reduce weight and intake of sodium 2

3 TOMHS SAS Dataset (1 Row per participant)
Demographics Age Gender Ethnicity Blood Pressure, Pulse and Weight Treatment group (1-6) Blood total and HDL cholesterol Serum potassium and glucose Data at baseline, 6-months, and 12-months

4

5 Graphing With SAS PROC SGPLOT PROC SGPANEL Histograms Box plots
Barcharts Scatter plots (regression line) Series plots PROC SGPANEL Paneled plots Example: Boxplots of Change in BP by Group, Paneled by visit

6

7 proc format; value sex 1 = 'Men' 2='Women'; value group 1='BB' 2='CCB' 3='Diuretic‘ 4='AB' 5='ACE' 6='Placebo'; value visit 0='Baseline' 6='Month 6' 12='Month 12'; value active 1='Active' 2='Placebo'; value race 1 = 'White' 2='Black' 3='Asian' 4='Other'; run;

8 * Reading in the data and defining variables;
libname t '.'; data temp; set t.tomhs; bmi = (wtbl* )/(height*height); sbpdif12 = sbp12 - sbpbl; if group in(1,2,3,4,5) then active = 1; else active = 2; run;

9 * Set up; ods graphics / reset noborder; ods listing ; * Writes each graph to a png file;

10 * Histogram using sgplot;
proc sgplot; histogram bmi; density bmi/type=normal; density bmi/type=kernel; yaxis label='Percent' grid ; xaxis label='BMI (kg/m2)'; title 'Histogram of BMI at Baseline in TOMHS'; run;

11 * Boxplots by Gender ; proc sgplot; vbox bmi/category=sex; yaxis label='BMI (kg/m2)' grid; xaxis display=(nolabel); title 'Boxplot of BMI at Baseline by Gender in TOMHS'; format sex sex.; run;

12 * Vertical bar chart; proc sgplot; vbar clinic/stat=freq datalabel; xaxis label='Clinical Center'; yaxis label='No. of Participants'; title 'Number of Perticipants Enrolled by Clinical Center in TOMHS'; run;

13 proc sgplot; vbar clinic/stat=percent datalabel; xaxis label='Clinical Center'; yaxis label='% of Participants' ; title 'Percent of Participants Enrolled by Clinical Center in TOMHS'; run;

14 * Response chart; proc sgplot noautolegend; vbar group/response=sbpdif12 stat=mean limitstat=stderr ; yaxis label = 'Mean SBP Change (mm Hg)'; xaxis label = 'Treatment Group'; title 'Mean Systolic BP Change at 12-Months by Group in TOMHS'; format group group.; run;

15 proc sgplot; vbar race/stat=freq datalabel group=sex groupdisplay=cluster name='sex'; xaxis label='Race/Ethnicity'; yaxis label='No. of Participants'; title 'Number of Participants Enrolled by Ethnicity and Gender in TOMHS'; keylegend 'sex' / title='' ; format race race.; format sex sex.; run;

16 * Standard scatter plot with regression line;
proc sgplot; reg y=sbpbl x=dbpbl; yaxis label = 'SBP (kg/m2)'; xaxis label = 'Age (y)'; title 'Scatter Plot of SBP Versus DBP at Baseline in TOMHS'; run;

17

18 * Create long format file;
data long; set temp; keep active visit sbp dbp; sbp = sbpbl; dbp = dbpbl; visit = 0; if sbp ne . then output; sbp = sbp6; dbp = dbp6; visit = 6; sbp = sbp12; dbp = dbp12; visit = 12; run;

19 Obs ptid active sbp dbp visit 1 A00001 139.5 87.0 2 122.0 74.0 6 3 A00010 144.0 90.5 4 117.0 5 129.0 71.0 12 A00021 141.0 7 116.0 65.0 8 118.0 69.0 9 A00023 134.0 92.5 10 139.0 92.0

20 * Create boxplots by group and visit using proc sgpanel;
proc sgpanel data=long noautolegend; panelby visit/columns=3 novarname ; rowaxis label='BP (mmHg)' grid; colaxis integer display=(nolabel); vbox sbp/category=active; format active active.; format visit visit.; title 'Boxplots of SBP by Visit and Group in TOMHS'; run;

21 proc sgpanel data=long noautolegend;
panelby visit/columns=3 novarname ; rowaxis label='BP (mmHg)' grid; colaxis display=(nolabel); vbox sbp/category=active group=active nofill nomean ; format active active.; format visit visit.; title 'Boxplots of SBP by Visit and Group in TOMHS'; styleattrs datacolors=(blue red); run;

22

23 output out=plot mean=msbp mdbp stderr=sesbp sedbp n=nsbp ndbp; run;
proc means nway; class active visit; var sbp dbp ; output out=plot mean=msbp mdbp stderr=sesbp sedbp n=nsbp ndbp; run; Obs active visit _TYPE_ _FREQ_ msbp mdbp sesbp sedbp nsbp ndbp 1 3 668 2 6 639 12 627 4 234 5 225 221

24 proc sgplot data=plot ;
series x=visit y=msbp/markers group=active ; xaxis label='Follow-up Visit' type=discrete ; yaxis label='SBP (mmHg)' grid ; title 'Average SBP Over Follow-up for Active and Placebo Groups in TOMHS'; format active active.; label active= 'Group'; run;

25

26 data plot; set plot (drop=_freq_ _type_); uppsbp = msbp + sesbp; lowsbp = msbp - sesbp; uppdbp = mdbp + sedbp; lowdbp = mdbp - sedbp; run;

27 proc sgplot data=plot ;
styleattrs datasymbols=(circlefilled diamondfilled); series x=visit y=msbp/markers group=active name='group'; scatter x=visit y=msbp/group=active yerrorlower=lowsbp yerrorupper=uppsbp ; xaxis label='Follow-up Visit' type=discrete offsetmin= offsetmax=0.05 ; yaxis label='SBP (mmHg)' grid minor; keylegend 'group' / title='' ; title 'Average SBP Over Follow-up for Active and Placebo Groups in TOMHS'; format active active.; label active= 'Group'; run;


Download ppt "Introduction to Graphing in SAS"

Similar presentations


Ads by Google