Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

macros

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

Point estimate and confidence interval

Axis and reference line

Style

Code generation

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:

Prerequisites

Change history

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

Time-to-event variables

Titles, axes, and style

Code generation

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:

Prerequisites

Change history

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”)


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 ;


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 ;


sp_split_plot

This is internal macro used in %swimmer_plot. This macro is main functionality including sgplot.


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

Axes and appearance

Code generation

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:

Prerequisites

Change history

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

Response definition

Durable response display

Grouping

Event labels

Layout and appearance

Style

Time scale

Code generation

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

URL:

https://github.com/PharmaForest/OncoPlotter

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

Grouping

Response definition

Output and layout

Code generation

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

URL:

https://github.com/PharmaForest/OncoPlotter

Author: Hiroki Yamanobe Update: 8Oct2025 : First release 27May2026 : Bug fixed for not using %sp_change. Updated program header 30July2026 : Updated program header to markdown