Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
phebbar-sas committed Apr 5, 2019
1 parent bbb698f commit f917e45
Show file tree
Hide file tree
Showing 10 changed files with 586 additions and 0 deletions.
87 changes: 87 additions & 0 deletions SD706-2019-Hebbar/ForestPlot_Subgrouped_94m5.sas
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
%let gpath=".";
%let dpi=300;
ods _all_ close;
ods listing gpath=&gpath image_dpi=&dpi;

/*--Add "Id" to identify subgroup headings from values --*/
data forest_subgroup;
label PCIGroup='PCI Group' Group='Therapy Group';
input Id Subgroup $3-27 Count Percent Mean Low High PCIGroup Group PValue;
datalines;
1 Overall 2166 100 1.3 0.9 1.5 17.2 15.6 .
1 Age . . . . . . . 0.05
2 <= 65 Yr 1534 71 1.5 1.05 1.9 17.0 13.2 .
2 > 65 Yr 632 29 0.8 0.6 1.25 17.8 21.3 .
1 Sex . . . . . . . 0.13
2 Male 1690 78 1.5 1.05 1.9 16.8 13.5 .
2 Female 476 22 0.8 0.6 1.3 18.3 22.9 .
1 Race or ethnic group . . . . . . . 0.52
2 Nonwhite 428 20 1.05 0.6 1.8 18.8 17.8 .
2 White 1738 80 1.2 0.85 1.6 16.7 15.0 .
1 From MI to Randomization . . . . . . . 0.81
2 <= 7 days 963 44 1.2 0.8 1.5 18.9 18.6 .
2 > 7 days 1203 56 1.15 0.75 1.5 15.9 12.9 .
1 Diabetes . . . . . . . 0.41
2 Yes 446 21 1.4 0.9 2.0 29.3 23.3 .
2 No 720 79 1.1 0.8 1.5 14.4 13.5 .
;
run;

/*--Set indent weight, add insets and horizontal bands--*/
data forest_subgroup_2;
set forest_subgroup end=last;
label countPct='No. of Patients (%)';
length tValue $20 tPos $8;
drop Count Percent val;

yVal=_n_;
if count ne . then CountPct=put(count, 4.0) || "(" || put(percent, 3.0) || ")";
indentWt=ifn(id EQ 1, 0, 1); /* indent sub headings */
val=mod(_N_-1, 6);
if val in (1:3) then ref=yVal;
output;

if last then do;
call missing (Id, subGroup, mean, low, high, pcigroup, group, countPct, indentWt, ref);
yVal+1;
xl=0.9; tValue='<--PCI Better'; tPos='left'; output;
xl=1.1; tValue='Therapy Better-->'; tPos='right'; output;
end;
run;

data attrmap;
length textweight $10;
id='text'; value='1'; textcolor='Black'; textsize=7; textweight='bold'; output;
id='text'; value='2'; textcolor='Black'; textsize=5; textweight='normal'; output;
run;


/*--Forest Plot--*/
options missing=' ';
ods listing style=htmlBlue;
ods graphics / reset width=5in height=3in imagename='Forest_Subgrouped_SG_V94';
footnote j=l h=6pt italic 'This visual is for discussion of graph features only.'
' The actual details should be customized by user to suit their application.';
proc sgplot data=forest_subgroup_2 noWall noBorder noCycleAttrs
dAttrMap=attrMap noAutoLegend ;
styleAttrs axisExtent=data;
refLine ref / lineAttrs=(color=cxe7e7f7) discretethickness=1;
highlow y=yVal low=low high=high;
scatter y=yVal x=mean / markerAttrs=(symbol=squarefilled size=4);
refLine 1 / axis=x;
refLine 1 / axis=x2 noclip transparency=1; /* dummy for x2 axis label */
text x=xl y=yVal text=tValue / position=tPos contributeoffsets=none;

yAxistable subgroup / location=inside position=left textGroup=id labelAttrs=(size=8)
textGroupId=text indentWeight=indentWt;
yAxistable countpct / location=inside position=left labelAttrs=(size=8) valueAttrs=(size=7) valueJustify=right;
yAxistable PCIGroup group pvalue / location=inside position=right labelAttrs=(size=8) valueAttrs=(size=7);

/* colorBands force axistable inner margin to be not opaque */
yAxis reverse display=none type=discrete colorbands=odd colorBandsAttrs=(transparency=1);
xAxis display=(nolabel) type=log values=( 0.5 1.0 2.0 4);
x2Axis label='Hazard Ratio' display=(noline noticks novalues) labelAttrs=(size=8);
run;

title;
footnote;
62 changes: 62 additions & 0 deletions SD706-2019-Hebbar/LFTShiftPanel.sas
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
%let gpath='.';
%let dpi=300;
ods listing style=htmlblue image_dpi=&dpi gpath=&gpath;
ods html close;

proc format;
value $drug
'A'='Drug A (N=209)'
'B'='Drug B (N=405)';
run;

/*--Generate some data--*/
data LFTShift;
keep Base Max Test Drug;
length Test $8;
label Base="Baseline (/ULN)";
label Max= "Maximum (/ULN)";

do Test= 'ALAT', 'ALKPH', 'ASAT', 'BILTOT';
do i=1 to 40;
do Drug = 'A', 'B';
Max = ranuni(5) + 0.1;
Base = Max - ranuni(2) + 0.3;
output;
end;
end;
end;
run;


/*--Add reference lines to data by test--*/
data LFTShift_Ref;
set LFTShift;
by test;
if first.test then do;
Ref=1; output;
Ref=ifn(test eq 'BILTOT', 1.5, 2); output;
end;
else output;
run;

/*--Panel with varying ref lines--*/
ods graphics / reset width=6in height=2.7in imagename="Panel_of_LFT_Shift_Ref";
title "LFT Shifts from Baseline to Maximum by Treatment";
footnote1 j=l "Clincal Concern Levels: ALAT, ASAT, ALKPH = 2 ULN, BILTOT = 1.5 ULN";
footnote2 j=c "-- where ULN is the Upper Level of Normal Range";

proc sgPanel data=LFTShift_Ref;
format Drug $drug.;
panelBy Test / layout=panel columns=4 spacing=10 noVarName;

lineParm x=0 y=0 slope=1 / lineattrs=graphgridlines;
scatter x=base y=max / group=drug;
refLine ref / axis=Y lineAttrs=(pattern=dash);
refLine ref / axis=X lineAttrs=(pattern=dash);
rowAxis integer min=0 max=4;
colAxis integer min=0 max=4;
keyLegend / title="" noborder;
run;

title;
footnote;
76 changes: 76 additions & 0 deletions SD706-2019-Hebbar/LabsPanel.sas
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
%let gpath='.';
%let dpi=300;

ods _all_ close;
ods listing style=htmlblue image_dpi=&dpi gpath=&gpath;

proc format;
value num2visit
1='PreRx'
2='Week 1'
3='Week 2'
4='Week 3'
5='Week 5'
6='Week 6'
;

value $testNameWithUnit
/* ODS Unicode escapes in formats! */
'WBC' = "WBC x 10(*ESC*){Unicode '00b3'x} /uL"
'Hemoglobin' = 'Hgb g/dL'
;
run;

/* Read in the CSV file -- input data */
%let dataDir=<your CSV file folder>;
proc import dataFile="&dataDir\labsPanel_data.csv" dbms=csv out=labs replace;
run;

proc sort data=labs;
by testName visitNum;
run;

data labs_mod;
format cellLabel $testNameWithUnit. visitNum num2Visit.;
set labs;
by testName;

if first.testName or last.testName then do;
bandLow = numLow;
bandHigh = numHigh;
end;
if first.testName then cellLabel=testName;
run;


option nobyline;


/*--Panel with Class labels--*/
ods graphics / reset noborder width=5in height=2.25in imageName='WBC_Panel_Band_Box_NoHeader';
title 'WBC and Differential: Weeks 1-6';
proc sgpanel data=labs_mod noAutoLegend;
panelby testName / onePanel uniscale=column layout=rowLattice
noHeader spacing=5;

band x=visitNum lower=bandLow upper=bandHigh / transparency=0.7
fillAttrs=(color=lightGreen);

refLine bandLow / label noClip lineAttrs=(color=lightGreen)
labelAttrs=(size=7) transparency=0.7;
refLine bandHigh / label noClip lineAttrs=(color=lightGreen)
labelAttrs=(size=7) transparency=0.7;

scatter x=visitNum y=result / transparency=0.8 jitter;
vbox result / category=visitNum noFill noOutliers lineAttrs=graphDataDefault;

inset cellLabel / position=topLeft noLabel textAttrs=(size=9);

rowAxis display=(noLine noLabel noTicks) offsetMax=0.18 valueAttrs=(size=7)
grid gridAttrs=(pattern=dot);
colAxis display=(noLine noLabel noTicks) valueAttrs=(size=7);
run;

title;
footnote;

Binary file added SD706-2019-Hebbar/LabsPanel_Data.zip
Binary file not shown.
41 changes: 41 additions & 0 deletions SD706-2019-Hebbar/Measles.sas
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
%let gpath='C:\Work\Sugi\SGF2016\SuperDemos\Clinical_Graphs\Image';
%let dpi=300;
ods html close;
ods listing gpath=&gpath image_dpi=&dpi;

data Measles;
input Year Cases Vaccine;
datalines;
1998 100 92
1999 120 88
2000 100 88
2001 400 87
2002 500 84
2003 450 82
2004 250 80
2005 150 81
2006 700 85
2007 1000 87
2008 1300 85
2009 1100 86
2010 500 88
2011 1000 89
2012 2000 91
;
run;
/*proc print;run;*/

ods graphics / reset attrpriority=color width=5in height=3in imagename='Measels';
title 'Measles Cases and MMR Uptake by Year';
proc sgplot data=Measles noborder;
vbar year / response=vaccine nostatlabel y2axis fillattrs=(color=green) filltype=gradient
baselineattrs=(thickness=0) baseline=0;
vline year / response=cases nostatlabel lineattrs=(color=red thickness=3);
keylegend / location=inside position=top linelength=15;
yaxis offsetmin=0 display=(noline noticks) thresholdmax=0 max=2500 grid
label='Measels Cases in England and Wales' labelattrs=(color=red);
y2axis offsetmin=0 min=0 max=95 display=(noline noticks) thresholdmax=0
label='MMR Uptake for England' labelattrs=(color=green);
xaxis display=(nolabel noticks) valueattrs=(size=7);
run;
title;
114 changes: 114 additions & 0 deletions SD706-2019-Hebbar/SurvivalPlot_94m5.sas
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
libname data '.';
%let gpath=".";
%let dpi=300;

/**
* The graph data set is created from LIFETEST procedure on sashelp.BMT
* by grabbing ods output SurivalPlotData.
* %include 'SurvivalPlot_Data.sas';
*/


/* Survival Plot with outer Risk Table using AxisTable and legendItem */
ods listing style=htmlblue image_dpi=&dpi gpath=&gpath;
ods graphics / reset width=5in height=3in imagename='Survival Plot';

title 'Product-Limit Survival Estimates';
title2 h=0.8 'With Number of Subjects at Risk';
footnote j=l h=6pt italic 'This visual is for discussion of graph features only.'
' The actual details should be customized by user to suit their application.';
proc sgplot data=data.SurvivalPlotData;
step x=time y=survival / group=stratum name='step';
scatter x=time y=censored / markerattrs=(symbol=plus) group=stratum;
xaxistable atrisk / x=tatrisk class=stratum colorgroup=stratum valueattrs=(weight=bold);

keylegend 'step' / linelength=20;

legendItem name='censored' type=marker / label="Censored" markerattrs=(symbol=plus);
keylegend 'censored' / location=inside position=topright;
run;

/*--Survival Plot with outer Risk Table using AxisTable with Ref line for Y axis--*/
ods listing style=htmlblue;
ods graphics / reset width=5in height=3in imagename='Survival Plot_Ref';
title 'Product-Limit Survival Estimates';
title2 h=0.8 'With Number of Subjects at Risk';
footnote j=l h=6pt italic 'This visual is for discussion of graph features only.'
' The actual details should be customized by user to suit their application.';
proc sgplot data=data.SurvivalPlotData noborder;
styleattrs axisextent=data;
dropline x=0 y=0.2 / dropto=y;
dropline x=0 y=0.4 / dropto=y;
dropline x=0 y=0.6 / dropto=y;
dropline x=0 y=0.8 / dropto=y;
dropline x=0 y=1.0 / dropto=y;
/* refline 0 / axis=x;*/
step x=time y=survival / group=stratum name='s';
scatter x=time y=censored / markerattrs=(symbol=plus) name='c';
scatter x=time y=censored / markerattrs=(symbol=plus) GROUP=stratum;
xaxistable atrisk / x=tatrisk class=stratum colorgroup=stratum valueattrs=(weight=bold);
keylegend 'c' / location=inside position=topright;
keylegend 's' / linelength=20;
yaxis display=(noline noticks);
run;


/*--Survival Plot with inner Risk Table using AxisTable--*/
ods listing style=htmlBlue;
ods graphics / reset width=5in height=3in imagename='Survival Plot_Inside';
title 'Product-Limit Survival Estimates';
title2 h=0.8 'With Number of Subjects at Risk';
footnote j=l h=6pt italic 'This visual is for discussion of graph features only.'
' The actual details should be customized by user to suit their application.';
proc sgplot data=data.SurvivalPlotData;
step x=time y=survival / group=stratum lineattrs=(pattern=solid) name='s';
scatter x=time y=censored / markerattrs=(symbol=plus) name='c';
scatter x=time y=censored / markerattrs=(symbol=plus) GROUP=stratum;
xaxistable atrisk / x=tatrisk location=inside class=stratum colorgroup=stratum
separator valueattrs=(size=7 weight=bold) labelattrs=(size=8);
keylegend 'c' / location=inside position=topright;
keylegend 's' / linelength=20;
run;


/*--Survival Plot with inner Risk Table using AxisTable--*/
ods graphics / reset width=5in height=3in imagename='Survival Plot_Ref_Inside';
title 'Product-Limit Survival Estimates';
title2 h=0.8 'With Number of Subjects at Risk';
*footnote j=l h=6pt italic 'This visual is for discussion of graph features only.'
' The actual details should be customized by user to suit their application.';
proc sgplot data=data.SurvivalPlotData noborder;
styleattrs axisextent=data;
dropline x=0 y=0.2 / dropto=y;
dropline x=0 y=0.4 / dropto=y;
dropline x=0 y=0.6 / dropto=y;
dropline x=0 y=0.8 / dropto=y;
dropline x=0 y=1.0 / dropto=both;
step x=time y=survival / group=stratum lineattrs=(pattern=solid) name='s';
scatter x=time y=censored / markerattrs=(symbol=plus) name='c';
scatter x=time y=censored / markerattrs=(symbol=plus) GROUP=stratum;
xaxistable atrisk / x=tatrisk location=inside class=stratum colorgroup=stratum
valueattrs=(size=7 weight=bold) labelattrs=(size=8);
keylegend 'c' / location=inside position=topright;
keylegend 's' / linelength=20;
yaxis display=(noline noticks);
run;


/*--Survival Plot with padding for annotation--*/
ods graphics / reset width=5in height=3in imagename='Survival_Plot_Pad';
title 'Product-Limit Survival Estimates';
title2 h=0.8 'With Number of Subjects at Risk';
*footnote j=l h=6pt italic 'This visual is for discussion of graph features only.'
' The actual details should be customized by user to suit their application.';
proc sgplot data=data.SurvivalPlotData pad=(bottom=20pct);
step x=time y=survival / group=stratum name='s';
scatter x=time y=censored / markerattrs=(symbol=plus) name='c';
scatter x=time y=censored / markerattrs=(symbol=plus) GROUP=stratum;
keylegend 'c' / location=inside position=topright;
keylegend 's' / linelength=20;
run;


title;
footnote;
12 changes: 12 additions & 0 deletions SD706-2019-Hebbar/SurvivalPlot_Data.sas
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
libname data '.';
ods _all_ close;
ods listing;

/*--Get survival plot data from LIFETEST procedure--*/
ods graphics on;
ods output SurvivalPlot=data.SurvivalPlotData;
ods select SurvivalPlot;
proc lifetest data=sashelp.BMT plots=survival(atrisk=0 to 2500 by 500);
time T * Status(0);
strata Group / test=logrank adjust=sidak;
run;
Loading

0 comments on commit f917e45

Please sign in to comment.