Published on :
Reporting CREATION_INTERNE

Tumor Size Change Graphs (Waterfall Plot)

This code is also available in: Deutsch Español Français
Awaiting validation
The script begins by creating a 'TumorSize' dataset simulating tumor size variation for 25 subjects across two treatment groups ('Treatment 1', 'Treatment 2'). It then generates two graphs. The first is a classic bar chart sorted by response. The second, after explicit data sorting, produces a similar but more advanced graph with a confidence band and a different bar appearance. The graphs are configured to be exported via ODS LISTING.
Data Analysis

Type : CREATION_INTERNE


The 'TumorSize' dataset is entirely generated in the first DATA step. It uses the ranuni function to simulate random data for 25 observations, representing patients and their tumor size variation.

1 Code Block
Configuration
Explanation :
This block initializes macro variables for the output path and image resolution. It closes the ODS HTML destination and configures the ODS LISTING destination for graph output.
Copied!
1%let gpath='.'; /*--Put your Folder Name here--*/
2%let dpi=300;
3ods html close;
4ods listing gpath=&gpath image_dpi=&dpi;
2 Code Block
DATA STEP Data
Explanation :
Generation of the 'TumorSize' table containing 25 observations. For each observation, an identifier (Cid), a change ('change'), a treatment group ('Group'), and a label ('Label') are randomly created.
Copied!
1DATA TumorSize;
2 LENGTH Cid $ 3;
3 label Change='Change from Baseline (%)';
4 DO Id=1 to 25;
5 cid=put(id, 2.0);
6 change=30-120*ranuni(2);
7 Group=ifc(int(ranuni(2)+0.5), 'Treatment 1', 'Treatment 2');
8 IF mod(id, 5) = 1 THEN Label='C';
9 IF mod(id, 5) = 2 THEN label='R';
10 IF mod(id, 5) = 3 THEN label='S';
11 IF mod(id, 5) = 4 THEN label='P';
12 IF mod(id, 5) = 0 THEN label='N';
13 OUTPUT;
14 END;
15RUN;
3 Code Block
PROC SGPLOT
Explanation :
Creation of a first bar chart ('waterfall plot') using the SGPLOT procedure. It represents the change ('change') for each patient (Cid), grouped by treatment. The bars are ordered by response value (descending). Reference lines and legends are added for context.
Copied!
1ods graphics / reset width=5in height=3in imagename='4_9_1_TumorSize_SG_V94';
2title 'Change in Tumor Size';
3title2 'ITT Population';
4PROC SGPLOT DATA=TumorSize nowall noborder;
5 styleattrs datacolors=(cxbf0000 cx4f4f4f) datacontrastcolors=(black);
6 vbar cid / response=change group=group categoryorder=respdesc datalabel=label
7 datalabelattrs=(size=5 weight=bold) groupdisplay=cluster clusterwidth=1;
8 refline 20 -30 / lineattrs=(pattern=shortdash);
9 xaxis display=none;
10 yaxis values=(60 to -100 BY -20);
11 inset ("C="="CR" "R="="PR" "S="="SD" "P="="PD" "N="="NE") / title='BCR'
12 position=bottomleft border textattrs=(size=6 weight=bold) titleattrs=(size=7);
13 keylegend / title='' location=inside position=topright across=1 border;
14RUN;
15title;
4 Code Block
PROC SORT Data
Explanation :
Sorting the 'TumorSize' table by the 'change' variable in descending order. The result is stored in a new table named 'TumorSizeDesc'.
Copied!
1 
2PROC SORT
3DATA=TumorSize out=TumorSizeDesc;
4BY descending change;
5RUN;
6 
5 Code Block
PROC SGPLOT
Explanation :
Creation of a second graph from the sorted data ('TumorSizeDesc'). It uses VBARPARM instead of VBAR because the data is already ordered. A band is added to mark a confidence zone (between -30 and 20). The appearance of the bars is modified with DATASKIN=PRESSED.
Copied!
1ods graphics / reset width=5in height=3in imagename='4_9_2_TumorSize_SG_V94';
2title 'Change in Tumor Size';
3title2 'ITT Population';
4PROC SGPLOT DATA=TumorSizeDesc nowall noborder;
5 styleattrs datacolors=(cxbf0000 gold) datacontrastcolors=(black) axisextent=DATA;
6 band x=cid upper=20 lower=-30 / transparency=0.5 fill nooutline legendlabel='Confidence';
7 vbarparm category=cid response=change / group=group datalabel=label
8 datalabelattrs=(size=5 weight=bold) groupdisplay=cluster
9 dataskin=pressed;
10 xaxis display=none;
11 yaxis values=(60 to -100 BY -20) grid gridattrs=(color=cxf0f0f0);
12 inset ("C="="CR" "R="="PR" "S="="SD" "P="="PD" "N="="NE") / title='BCR'
13 position=bottomleft border textattrs=(size=6 weight=bold) titleattrs=(size=7);
14 keylegend / title='' location=inside position=topright across=1 border opaque;
15RUN;
16title;
This material is provided "as is" by We Are Cas. There are no warranties, expressed or implied, as to merchantability or fitness for a particular purpose regarding the materials or code contained herein. We Are Cas is not responsible for errors in this material as it now exists or will exist, nor does We Are Cas provide technical support for it.