Sample 39078: Adverse events for patient ID
This sample illustrates how to create a time line using the SCATTER and VECTOR statements in the SGPLOT procedure.
These sample files and code examples are provided by SAS Institute
Inc. "as is" without warranty of any kind, either express or implied, including
but not limited to the implied warranties of merchantability and fitness for a
particular purpose. Recipients acknowledge and agree that SAS Institute shall
not be liable for any damages whatsoever arising out of their use of this material.
In addition, SAS Institute will provide no support for the materials contained herein.
This sample illustrates how to create a time line using the SCATTER and VECTOR statements in the SGPLOT procedure.
data ae0;
attrib aestdate informat=yymmdd10. format=yymmdd10.;
attrib aeendate informat=yymmdd10. format=yymmdd10.;
input aeseq aedecod $ 5-39 aesev $ aestdate aeendate aestdy aeendy;
cards;
1 DIZZINESS MODERATE 2013-03-06 2013-03-06 3 3
2 COUGH MILD 2013-03-20 . 17 .
3 APPLICATION SITE DERMATITIS MILD 2013-03-26 2013-06-18 23 107
4 DIZZINESS MILD 2013-03-27 2013-03-27 24 24
5 ELECTROCARDIOGRAM T WAVE INVERSION MILD 2013-03-30 . 27 .
6 DIZZINESS MILD 2013-04-01 2013-04-11 29 39
7 DIZZINESS MILD 2013-04-01 2013-04-11 29 39
8 APPLICATION SITE DERMATITIS MODERATE 2013-03-26 2013-06-18 23 107
9 HEADACHE MILD 2013-05-17 2013-05-18 75 76
10 APPLICATION SITE DERMATITIS MODERATE 2013-03-26 2013-06-18 23 107
11 PRURITUS MODERATE 2013-05-27 2013-06-18 85 107
;
run;
%let grwidth=700;
%let grwpx=700px;
ods escapechar="^";
proc template;
define Style SDD; parent = styles.default;
style GraphColors from graphcolors /
"gcdata" = cx0000df
"gcdata1" = cx00af00
"gcdata2" = cxcfaf00
"gcdata3" = cxaf0000
;
end;
run;
data ae1;
set ae0 end=eof;
format mindate maxdate YYMMDD10.;
retain minday maxday mindate maxdate;
if ( _n_ = 1) then do;
minday=aestdy;
if aeendy = . then maxday = aestdy;
else maxday=aeendy;
mindate=aestdate;
if endate = . then maxdate = endate;
else maxdate=endate;
end;
if aestdy < minday then minday = aestdy;
if aeendy > maxday then maxday = aeendy;
if aestdate < mindate then mindate = aestdate;
if aeendate > maxdate then maxdate = aeendate;
if ( eof = 1 ) then do;
call symputx('minday', minday);
call symputx('maxday', maxday);
call symputx('mindate', mindate);
call symputx('maxdate', maxdate);
end;
run;
data ae2;
set ae1 nobs=nobs;
length graphht $6;
format lastdate YYMMDD10. lastday BEST12.;
y=10*aeseq/nobs;
yc=y-0.3;
graphht=put(15*nobs+300, 4.);
graphht = cats(graphht, "px");
call symputx('grhtAE', graphht); /*--AE Graph height--*/
if aeendy = . then lastday= symget('maxday');
else lastday= aeendy;
if aeendate = . then lastdate = symget('maxdate');
else lastdate = aeenddate;
if aesev = 'MILD' then sev=1;
else if aesev = 'MODERATE' then sev=2;
else if aesev = 'SEVERE' then sev=3;
else sev=4;
run;
/* Find corresponding min date for minday = -10 */
data _null_;
min = -10;
delta = min - &minday;
mindate2 = &mindate + delta;
call symputx('mindate2', mindate2);
call symputx('minday2', min);
run;
/* Create severity data to ensure all severity values are in the data set. */
data severity;
input aesev $ xs ys;
datalines;
MILD -100 -100
MODERATE -100 -100
SEVERE -100 -100
;
run;
/* Merge severity data into time line data. */
/* Find delta X for positioning of marker character. */
data ae;
set severity ae2;
len = length(aedecod)+3;
dur = abs(&maxday - &minday2);
xoff=len*dur / &grwidth;
xc=aestdy-3.4*xoff;
run;
/* Create Adverse Effects graph */
ods listing close;
ods html style=sdd image_dpi=100 file='timeline.html' path='.';
ods graphics / reset noborder width=600px height=400px
imagename="ClinicalHandout_AETimeline" imagefmt=gif noscale;
title "Adverse Events for Patient Id = xx-xxx-xxxx";
proc sgplot data=ae noautolegend nocycleattrs;
refline 0 / axis=x lineattrs=(thickness=1 color=black);
vector x=xs y=ys / xorigin=-110 yorigin = -110 group=aesev lineattrs=(thickness=9px pattern=solid) name='sev';
vector x=lastday y=y / xorigin=aestdy yorigin=y noarrowheads lineattrs=(thickness=13px pattern=solid color=black)
group=aesev;
vector x=lastday y=y / xorigin=aestdy yorigin=y noarrowheads lineattrs=(thickness=9px pattern=solid color=white)
group=aesev;
vector x=lastday y=y / xorigin=aestdy yorigin=y noarrowheads lineattrs=(thickness=9px pattern=solid)
transparency=0.4 group=aesev;
scatter x=aestdy y=y / markerattrs=graphdatadefault(size=15px symbol=trianglefilled color=black); /*--Outlines--*/
scatter x=aestdy y=y / markerattrs=(size=11px symbol=trianglefilled) group=aesev;
scatter x=aeendy y=y / markerattrs=graphdatadefault(size=15px symbol=trianglefilled color=black); /*--Outlines--*/
scatter x=aeendy y=y / markerattrs=(size=11px symbol=trianglefilled) group=aesev;
scatter x=xc y=y / markerchar=aedecod markercharattrs=(size=6);
scatter x=aestdate y=y / markerattrs=(size=0) x2axis;
yaxis display=(nolabel noticks novalues) min=0;
xaxis grid label='Study Days' offsetmin=0.03 offsetmax=0.02 values=(&minday2 to &maxday by 2);
x2axis notimesplit display=(nolabel) tickvalueformat=date7. offsetmin=0.03 offsetmax=0.02 values=(&mindate2 to &maxdate);
keylegend 'sev'/ title='Severity :';
run;
ods html close;
ods listing;
These sample files and code examples are provided by SAS Institute
Inc. "as is" without warranty of any kind, either express or implied, including
but not limited to the implied warranties of merchantability and fitness for a
particular purpose. Recipients acknowledge and agree that SAS Institute shall
not be liable for any damages whatsoever arising out of their use of this material.
In addition, SAS Institute will provide no support for the materials contained herein.
This sample illustrates how to create a time line using the SCATTER and VECTOR statements in the SGPLOT procedure.
Type: | Sample |
Topic: | SAS Reference ==> Procedures ==> SGPLOT Query and Reporting ==> Creating Reports ==> Graphical ==> Health and Life Sciences Industry
|
Date Modified: | 2010-04-07 15:23:08 |
Date Created: | 2010-03-18 15:42:33 |
Operating System and Release Information
SAS System | SAS/GRAPH | z/OS | 9.2 TS2M0 | |
Microsoft® Windows® for 64-Bit Itanium-based Systems | 9.2 TS2M0 | |
Microsoft Windows Server 2003 Datacenter 64-bit Edition | 9.2 TS2M0 | |
Microsoft Windows Server 2003 Enterprise 64-bit Edition | 9.2 TS2M0 | |
Microsoft Windows XP 64-bit Edition | 9.2 TS2M0 | |
Microsoft® Windows® for x64 | 9.2 TS2M0 | |
Microsoft Windows Server 2003 Datacenter Edition | 9.2 TS2M0 | |
Microsoft Windows Server 2003 Enterprise Edition | 9.2 TS2M0 | |
Microsoft Windows Server 2003 Standard Edition | 9.2 TS2M0 | |
Microsoft Windows XP Professional | 9.2 TS2M0 | |
Windows Vista | 9.2 TS2M0 | |
64-bit Enabled AIX | 9.2 TS2M0 | |
64-bit Enabled HP-UX | 9.2 TS2M0 | |
64-bit Enabled Solaris | 9.2 TS2M0 | |
HP-UX IPF | 9.2 TS2M0 | |
Linux | 9.2 TS2M0 | |
Linux for x64 | 9.2 TS2M0 | |
OpenVMS on HP Integrity | 9.2 TS2M0 | |
Solaris for x64 | 9.2 TS2M0 | |