forest_plot¶
Macro:¶
Purpose:¶
Creates a forest plot using PROC SGPLOT to display point estimates and
confidence intervals. Up to six descriptive columns can be shown on the left
side of the plot using YAXISTABLE. An optional reference line and generated
SAS code output are also supported.
Parameters:¶
Input data and display columns¶
data(optional, default=dummy_forest_test) : Input dataset used to create the forest plot.out1(optional, default=col1) : First descriptive variable displayed on the left side of the plot.out2-out6(optional, default=blank) : Additional descriptive variables displayed on the left side of the plot.out1_label(optional, default=Sub Group) : Column label forout1.out2_label-out6_label(optional, default=blank) : Column labels forout2throughout6.
Point estimate and confidence interval¶
marker_point(optional, default=estimate) : Numeric variable containing the point estimate.bar_left(optional, default=lower_limit) : Numeric variable containing the lower confidence limit.bar_right(optional, default=upper_limit) : Numeric variable containing the upper confidence limit.
Axis and reference line¶
AxisValues(optional, default=0.0 to 2.5 by 0.5) : X-axis tick specification passed toXAXIS VALUES=().refline_value(optional, default=1) : Value at which a vertical reference line is drawn. Leave blank to suppress the reference line.
Style¶
bar_color(optional, default=black) : Color of the confidence interval bars.marker_color(optional, default=black) : Color of the point-estimate markers.
Code generation¶
Generate_Code(optional, default=N) : When set toY, generates the expanded SAS program code and writes it to a text file in the WORK directory.
Example¶
%forest_plot(
data = dummy_forest_test,
out1 = col1,
out2 = col2,
out3 = col3,
out4 = col4,
out5 = col5,
marker_point = estimate,
bar_left = lower_limit,
bar_right = upper_limit,
out1_label = %nrbquote(Sub Group),
out2_label = %nrbquote(n),
out3_label = %nrbquote(%),
out4_label = %nrbquote(HR),
out5_label = %nrbquote(HR 95 %CL),
AxisValues = %nrbquote(0.0 to 2.5 by 0.5),
refline_value = 1,
bar_color = black,
marker_color = black,
Generate_Code = Y
);Output:¶
Forest plot generated by ODS Graphics
WORK.wk_forest: plotting datasetWORK.forest_anno: SG annotation datasetforest_plot<index>.txt: generated SAS code whenGenerate_Code=Y
Prerequisites¶
An input dataset containing:
Variables specified in
out1throughout6, as applicableThe point-estimate variable specified in
marker_pointThe lower and upper confidence-limit variables specified in
bar_leftandbar_right
Change history¶
2026-02-05: First release
2026-07-30: Removed
ODS GRAPHICS RESET, updated program header to markdown
Author¶
Yutaka Morioka
kaplan_meier_plot¶
Macro:¶
Purpose:¶
Creates Kaplan-Meier survival plots using PROC LIFETEST and PROC SGPLOT.
The macro displays survival curves by group, censoring marks, and the number of
subjects at risk at specified time points.
Parameters:¶
Input data and grouping¶
data(optional, default=dummy_adtte) : Input time-to-event analysis dataset.groupn(optional, default=TRTPN) : Numeric grouping variable used to define the survival curves.groupc(optional, default=TRTP) : Character variable containing the display label for each group.wh(optional, default=blank) : WHERE condition used to subset the input dataset.
Time-to-event variables¶
Time_var(optional, default=AVAL) : Numeric time-to-event analysis variable.Censor_var(optional, default=blank) : Censoring indicator variable.Censor_val(optional, default=blank) : Value ofCensor_varthat identifies censored observations.Censore_var(deprecated, default=CNSR) : Previous name ofCensor_var, retained for backward compatibility. It is used only whenCensor_varis blank.Censore_val(deprecated, default=1) : Previous name ofCensor_val, retained for backward compatibility. It is used only whenCensor_valis blank.
Titles, axes, and style¶
Title(optional, default=Kaplan-Meier Plot) : Title displayed above the plot.Group_color_list(optional, default=black black black black) : Space-separated list of colors used for the group survival curves.Group_linepattern_list(optional, default=solid shortdash longdash dash) : Space-separated list of line patterns used for the group survival curves.XLABEL(optional, default=Survival Time (Month)) : Label displayed on the X-axis.YLABEL(optional, default=Probability of Survival) : Label displayed on the Y-axis.AxisValues(optional, default=0 to 16 by 2) : X-axis tick specification and time points used for the number-at-risk table.
Code generation¶
Generate_Code(optional, default=Y) : When set toY, generates the expanded SAS program code and writes it to a text file in the WORK directory.
Example¶
%kaplan_meier_plot(
data = dummy_adtte,
groupn = TRTPN,
groupc = TRTP,
Time_var = AVAL,
Censor_var = CNSR,
Censor_val = 1,
Title = %nrbquote(Kaplan-Meier Curve Example),
Group_color_list = %nrbquote(black red blue green),
Group_linepattern_list = %nrbquote(solid dash longdash shortdash),
XLABEL = %nrbquote(Survival Time (Month)),
YLABEL = %nrbquote(Probability),
AxisValues = %nrbquote(0 to 24 by 4),
Generate_Code = Y
);Output:¶
Kaplan-Meier survival plot generated by ODS Graphics
Number-at-risk table displayed below the survival curves
Intermediate datasets including
SurvivalPlotData,Stratum,tAtRisk,atrisk, andSurvivalPlotData_1kaplan_meier_plot<index>.txt: generated SAS code whenGenerate_Code=Y
Prerequisites¶
SAS/STAT with
PROC LIFETESTAn input dataset containing:
The grouping variables specified in
groupnandgroupcThe time-to-event variable specified in
Time_varThe censoring variable specified in
Censor_var
Change history¶
2025-06-24: First release
2025-09-01: Bug fix
2025-09-16: Minor change
2026-02-05: Fixed generated-code output
2026-02-23: Renamed
Censore_varandCensore_valtoCensor_varandCensor_val2026-04-03: Removed
ODS GRAPHICS RESET2026-07-30: Updated program header to markdown
Author¶
Yutaka Morioka
sp_change¶
This is internal utility macro previously used in %swimmer_plot and %waterfall_plot until v0.5.1, but no longer used.
Purpose: Change separater of | to “”,“” (e.g. CR | PR | SD -> “CR”,“PR”,“SD”)
Author: Ryo Nakaya
Date: 2025-07-05 2026-05-27 : Bug fixed (added “G” in call symputx)
sp_make_groupf_format¶
This is internal utility macro used in %swimmer_plot.
Purpose:
Create format for groupvar (e.g.
proc format ;
value groupf
1 = “Stage I”
2 = “Stage II”
;
run ;
Author: Ryo Nakaya
Date: 2025-07-05
Version: 0.1
sp_make_respf_format¶
This is internal utility macro used in %swimmer_plot.
Purpose:
Create format for response (e.g.
proc format ;
value respf
1 = “CR”
2 = “PR”
;
run ;
Author: Ryo Nakaya
Date: 2025-07-05
Version: 0.1
sp_split_plot¶
This is internal macro used in %swimmer_plot.
This macro is main functionality including sgplot.
Author: Ryo Nakaya
Latest Date: 2025-10-29
spider_plot¶
Macro:¶
Purpose:¶
Creates a spider plot (subject profile plot) using PROC SGPLOT.
The macro draws a series line with markers for each subject across the specified
X and Y variables. Optional reference lines, subject categories, axis settings,
and generated SAS code output are supported.
A dummy input dataset is created within the macro for demonstration.
Parameters:¶
Input data and variables¶
data(optional, default=dummy_spider) : Input dataset.xvar(optional, default=ADY) : Variable displayed on the X-axis, such as analysis day.yvar(optional, default=PCHG) : Variable displayed on the Y-axis, such as percent change from baseline.subject_var(optional, default=SUBJID) : Subject identifier used as theGROUP=variable in theSERIESstatement.subject_category(optional, default=BOR) : Category variable used withGROUPLC=andGROUPMC=to control the line and marker colors. Leave blank when category-based coloring is not required.
Axes and appearance¶
xaxis_label(optional, default=Days) : Label displayed on the X-axis.xaxis_values(optional, default=0 43 85 127 169 191 213 235) : Value specification passed toXAXIS VALUES=().yaxis_label(optional, default=Change rate from baseline (%)) : Label displayed on the Y-axis.yaxis_values(optional, default=-100 -75 -50 -30 0 20 50 75 100) : Value specification passed toYAXIS VALUES=().datacontrastcolors(optional, default=Blue Red Green Yellow) : Space-separated color list passed toSTYLEATTRS DATACONTRASTCOLORS=().refline_value(optional, default=0 20 -30) : One or more Y-axis values at which horizontal reference lines are displayed. Leave blank to suppress reference lines.curvelabel(optional, default=Y) : When set toY, displays curve labels on the subject series.
Code generation¶
Generate_Code(optional, default=N) : When set toY, generates the expanded SAS program code, writes it to a text file in the WORK directory, and opens the file when supported.
Example¶
%spider_plot(
data = dummy_spider,
xvar = ADY,
yvar = PCHG,
subject_var = SUBJID,
subject_category = BOR,
xaxis_label = %nrbquote(Days),
xaxis_values = %nrbquote(0 43 85 127 169 191 213 235),
yaxis_label = %nrbquote(Change rate from baseline (%)),
yaxis_values = %nrbquote(-100 -75 -50 -30 0 20 50 75 100),
datacontrastcolors = %nrbquote(Blue Red Green Yellow),
refline_value = 0 20 -30,
curvelabel = Y,
Generate_Code = N
);Output:¶
Spider plot generated by ODS Graphics
WORK.dummy_spider: demonstration dataset created within the macrospider_plot<index>.txt: generated SAS code whenGenerate_Code=Y
Prerequisites¶
SAS with ODS Graphics and
PROC SGPLOTAn input dataset containing:
The variables specified in
xvarandyvarThe subject identifier specified in
subject_varThe category variable specified in
subject_category, when provided
Change history¶
2026-02-09: First release
2026-07-30:
ODS GRAPHICS RESET, updated program header to markdown
Author¶
Yutaka Morioka
swimmer_plot¶
Macro:¶
Purpose:¶
Creates a swimmer plot to visualize treatment duration, response duration (CR/PR), and clinical events (e.g., death) for each subject using ADaM datasets.
Parameters:¶
Data inputs¶
adrs(required) : Response dataset (BDS ADaM). Expected variables includeUSUBJID,AVAL,AVALC,ADT,ADY.adsl(required) : Subject-level dataset (ADSL ADaM). Expected variables includeUSUBJID,SUBJID,TRTSDT,TRTEDT,DTHDTand the variable specified ineotvar.whr_adrs(optional, default=blank) : WHERE condition applied to the response dataset.whr_adsl(optional, default=blank) : WHERE condition applied to the subject-level dataset.eotvar(required) : End-of-treatment status variable. If its value equals"ONGOING"(case-insensitive), an arrow endcap is drawn.lstvstdt(optional, default=blank) : Alternative last visit date used whenTRTEDTis missing or incomplete. Treatment duration is calculated asmin(TRTEDT, lstvstdt) - TRTSDT + 1.
Response definition¶
crprN(optional, default=1 2) : Numeric values ofAVALconsidered as CR or PR.responseN(required, default=1 2 3 4) : Numeric values of response categories.responseC(required, default=CR | PR | SD | PD) : Character labels corresponding toresponseN. Values must be separated by|.responseLabel(optional, default=Response) : Label for response legend.
Durable response display¶
durable(optional, default=Y) : Specifies whether response-duration (durable period) lines are drawn.durableLabel(optional, default=Response period) : Legend label for the durable response period.
Grouping¶
groupvar(optional, default=blank) : Numeric grouping variable inadsl.groupN(optional, default=blank) : Numeric values for the grouping variable.groupC(optional, default=blank) : Character labels for the grouping variable. Values must be separated by|.groupLabel(optional, default=blank) : Legend label for grouping categories.
Event labels¶
deathLabel(optional, default=Death) : Legend label for death marker.ongoingLabel(optional, default=Treatment Ongoing) : Legend label for ongoing-treatment indicator.
Layout and appearance¶
nperpage(optional, default=20) : Number of subjects displayed per page.width(optional, default=640) : Width of the output graphic in pixels.height(optional, default=480) : Height of the output graphic in pixels.subjidOn(optional, default=Y) : Displays subject ID when set toY.title(optional, default=blank) : Title of the plot.ytitle(optional, default=Subject) : Title of the y-axis.xtitle(optional, default=Days from Treatment Start) : Title of the x-axis.xvalues(optional, default=blank) : X-axis tick specification (e.g.,0 to 40 by 4).nolegend(optional, default=blank) : Suppresses legend when set toY.
Style¶
colorStyle(optional, default=OncoPlotter) : Preset color style. Supported values includeOncoPlotter,Salmon,Kawaii,Kyoto,Osaka.groupColor(optional, default=orange) : Color for group categories whencolorStyleis blank.markerColor(optional, default=red) : Color for markers whencolorStyleis blank.markerSymbol(optional, default=blank) : Marker symbol whencolorStyleis blank.
Time scale¶
interval(optional, default=blank) : Time-unit conversion. Permitted values (case-insensitive):WEEK: days divided by 7MONTH: days divided by 30.4375
Code generation¶
Generate_Code(optional, default=Y) : When set toY, generates the underlying program code and writes it to a text file in the WORK directory.
Example¶
%Swimmer_Plot(
adrs = adrs_dummy,
adsl = adsl_dummy,
whr_adrs = PARAM="Overall Response" and PARQUAL="IRC",
whr_adsl = FASFL="Y",
eotvar = EOTSTT,
lstvstdt = ,
crprN = 1 2,
durable = Y,
durableLabel = Durable Period,
groupvar = STAGEN,
groupLabel = Disease Stage,
groupN = 1 2 3 4 5,
groupC = Stage I | Stage IIa | Stage IIb | Stage III | Stage IV,
responseN = 1 2 3 4,
responseC = CR | PR | SD | PD,
responseLabel = Response,
deathLabel = Death,
ongoingLabel = Treatment Ongoing,
nperpage = 20,
width = 640,
height = 480,
subjidOn = Y,
colorStyle = OncoPlotter,
groupColor = ,
markerColor = ,
markerSymbol = ,
title = Swimmer%str(%')s Plot,
ytitle = Subject,
xtitle = Days from treatment,
xvalues = 0 to 40 by 4,
nolegend = ,
interval = week,
Generate_Code = Y
)prerequisites¶
Response data : BDS ADaM dataset (USUBJID, AVAL, ADT, ADY)
Subject-level-data : ADSL ADaM dataset (USUBJID, SUBJID, TRTSDT, TRTEDT, DTHDT)
URL:¶
https://
Author: Ryo Nakaya
Update:
5July2025 : First release
14July2025 : Added functionality of output generated SAS codes
23July2025 : A bug fixed and made modification to handle no groupvar
29Oct2025 : A bug fixed
2Oct2025 : A bug fixed for options of ods graphics
29Jan2026 : Default parameters have been changed
27May2026 : Bug fixed for not using %sp_change. Updated program header
30July2026 : Updated program header
waterfall_plot¶
Macro:¶
Purpose:¶
Creates a waterfall plot using ADaM datasets (ADSL, ADTR, and ADRS)
to visualize percent change in tumor size from baseline for each subject.
Parameters:¶
Data inputs¶
adrs(optional, default=ADRS) : Response dataset (e.g., ADRS containing Best Overall Response). Expected variables includeUSUBJIDand the variable specified ingroupVar.adtr(optional, default=ADTR) : Tumor measurement dataset (e.g., ADTR containing sum of diameters). Expected variables includeUSUBJIDand the variable specified inresponseVar.adsl(optional, default=ADSL) : Subject-level dataset (ADSL ADaM). Expected variable includesUSUBJID.whr_adrs(optional, default=blank) : WHERE condition applied to the response dataset. For example,PARAM="Best Overall Response".whr_adtr(optional, default=blank) : WHERE condition applied to the tumor measurement dataset. For example,PARAM="Sum of Diameters" and PARQUAL="IRC" and TRGRPID="TARGET" and ANL01FL="Y".whr_adsl(optional, default=blank) : WHERE condition applied to the subject-level dataset. For example,FASFL="Y".
Grouping¶
groupVar(required) : Numeric variable used to group subjects, such as the numeric value of Best Overall Response.groupLabel(optional, default=blank) : Legend title for the grouping variable.groupN(required) : Numeric values for the grouping variable.groupC(required) : Character labels corresponding togroupN. Values must be separated by|.groupColor(required) : Colors corresponding to the groups. Values must be separated by|.
Response definition¶
responseVar(required) : Numeric variable plotted on the y-axis, such as percent change from baseline.VarWidth(optional, default=0.7) : Width of each waterfall bar.
Output and layout¶
width(optional, default=840) : Width of the output graphic in pixels.height(optional, default=480) : Height of the output graphic in pixels.dpi(optional, default=300) : Resolution of the output graphic in dots per inch.imgPath(optional, default=SAS temporary directory) : Directory in which the image and HTML output files are written.title(optional, default=blank) : Title of the plot.ytitle(optional, default=Change from Baseline (%)) : Title of the y-axis.yvalues(optional, default=-100 to 100 by 20) : Y-axis tick specification.y_refline(optional, default=blank) : Space-separated y-axis reference-line values, such as-30 20.
Code generation¶
Generate_Code(optional, default=Y) : When set toY, generates the underlying SAS program code and writes it to a text file in the WORK directory.
Example¶
%Waterfall_Plot(
adrs = adrs_dummy,
adtr = adtr_dummy,
adsl = adsl_dummy,
whr_adrs = PARAM="Best Overall Response",
whr_adtr = PARAM="Sum of Diameters" and PARQUAL="IRC" and TRGRPID="TARGET" and ANL01FL="Y",
whr_adsl = FASFL="Y",
groupVar = AVAL,
groupN = 1 2 3 4,
groupC = CR | PR | SD | PD,
groupLabel = Best Overall Response:,
groupColor = green | blue | gray | red,
responseVar = PCHG,
VarWidth = 0.7,
width = 840,
height = 480,
dpi = 300,
imgPath = C:/temp,
title = Figure 14.2.x,
ytitle = Change from Baseline (%),
yvalues = -100 to 100 by 20,
y_refline = -30 20,
Generate_Code = Y
);Prerequisites¶
Response data: ADRS or another response dataset (
USUBJIDand the variable specified ingroupVar)Tumor measurement data: ADTR or another BDS ADaM dataset (
USUBJIDand the variable specified inresponseVar)Subject-level data: ADSL ADaM dataset (
USUBJID)
URL:¶
https://
Author: Hiroki Yamanobe Update: 8Oct2025 : First release 27May2026 : Bug fixed for not using %sp_change. Updated program header 30July2026 : Updated program header to markdown