Skip to content

PharmaForest/sashighlight

Repository files navigation

sashighlight

SAS Highlight is a utility package designed to visually highlight data points, subjects, or groups that meet specific conditions in ODS Graphics plots.
image

The package focuses on commonly used exploratory and review graphics in clinical and analytical workflows, especially:

  • Spaghetti plots
  • Scatter plots Highlighting can be performed based on user-defined conditions, either by subject (e.g. SUBJID, USUBJID) or by group (e.g. TRTP, TRTA).
    Main features include:
  • Subject-level highlighting in spaghetti plots
  • Group-level highlighting in spaghetti plots
  • Subject-level highlighting in scatter plots
  • Group-level highlighting in scatter plots

The package is designed to separate highlighting logic from plotting logic, allowing users to apply consistent visual highlight across multiple plots with minimal code duplication.

Typical usage example

%fig_setup;
%highlight_series(Dataset =mylib1.dummy_testdata02, 
                                            Highlight_Cond = %str(USUBJID = 10001), 
                                            Group_var = TRTAN, 
                                            Subject_var = USUBJID, 
                                            Value_var = AVAL, 
                                            Time_var = ADY, 
                                            Xaxis_labelnm = %str(Days), 
                                            Yaxis_labelnm = %str(Parameter (Unit)), 
                                            Xmin = 0, 
                                            Xmax = 140, 
                                            Xinc = 7, 
                                            Ymin = 175, 
                                            Ymax = 225, 
                                            Yinc = 25, 
                                            Outdir = %str(\\...),  
                                            Fignm = dummy02, 
                                            Figfmt= PDF
                                            );
image

%fig_setup() macro

Purpose:

Basic settings for the figure display. 

Note:

  • From color 0 to color 9 were based on the seaborn color palette.
  • This macro must be executed first to initialize the font and color settings for the figure.

%highlight_attrmap() macro

Purpose:

This macro sets up attribute map and included in highlight_series macro.   

Note:

Users can customize the program within the macro as needed to build the attribute map required for this package.

Parameters:

 - `Num_group_var =     Numerical group variables (e.g. TRTAN)

Example usage:

%highlight_attrmap(
  Group_var = TRTAN
  );

%highlight_refline() macro

Purpose:

This macro displays reference lines on the X-axis and Yaxis respectively, and includes in 'highlight_scatter_by_individual' and 'highlight_scatter_by_group' macro.   

Note:

Users can customize the line patterns, colors, and other settings if needed.

Parameters:

 - 'x_refval =     Reference line values on the X-axis (e.g. 100)
 - 'y_refval =     Reference line values on the Y-axis (e.g. 120)

Example usage:

  %highlight_refline(
  x_refval = 100, 
  y_refval = 120);

%highlight_spaghetti() macro

Purpose:

This macro highlights only the plots in the spaghetti plot that meet specific conditions.   

Parameters:

 - 'Dataset = Input dataset name (e.g. ADLB)  
 - 'Highlight_Cond = Set conditions to identify data to be highlighted. (e.g. %str(USUBJID = 10001), %str(TRTAN = 1))

In addition to specifying subject numbers, it is also possible to specify summary statistics(mean, std, min, max, and quartiles(min, median, max)) for evaluation items to be set on the Y-axis. (e.g. %str(min > 100 and max < 200))

 - 'Subject_var = Set the variable representing the Sunject ID. (e.g. SUBJID)
 - 'Value_var = Set the value to display on the Y-axis. (e.g. AVAL)
 - 'Time_var = Set the value to display on the X-axis. (e.g. ADY)
 - 'Xaxis_labelnm = X-axis label name (e.g. %str(Days))
 - 'Yaxis_labelnm = Y-axis label name (e.g. %str(Hemoglobin (g/dL)))
 - 'Xmin = Set the minimum value for the X-axis (e.g. 0)
 - 'Xmax = Set the maximum value for the X-axis (e.g. 200)
 - 'Xinc = Set the increment value for the X-axis (e.g. 50)
 - 'Ymin = Set the minimum value for the Y-axis (e.g. -100)
 - 'Ymax = Set the maximum value for the Y-axis (e.g. 100)
 - 'Yinc = Set the increment value for the Y-axis (e.g. 100)
 - 'Outdir = Figure file output directory
 - 'Fignm = Figure name (e.g. dummy01)
 - 'FIgfmt = Figure format (e.g. PNG)

Example usage:

%highlight_spaghetti(Dataset =dummy_testdata01, 
                                            Highlight_Cond = %str(USUBJID = 10001), 
                                            Subject_var = USUBJID, 
                                            Value_var = AVAL, 
                                            Time_var = ADY, 
                                            Xaxis_labelnm = %str(Days), 
                                            Yaxis_labelnm = %str(Parameter (Unit)), 
                                            Xmin = 0, 
                                            Xmax = 140, 
                                            Xinc = 7, 
                                            Ymin = 175, 
                                            Ymax = 225, 
                                            Yinc = 25, 
                                            Outdir = %str(\\...), 
                                            Fignm = Spaghetti, 
                                            Figfmt= PNG
                                            );

%highlight_series() macro

Purpose:

This macro highlights only the plots by group in the spaghetti plot that meet specific conditions.  

Parameters:

 - 'Dataset = Input dataset name (e.g. ADLB)
 - 'Highlight_Cond = Set conditions to identify data to be highlighted. (e.g. %str(USUBJID = 10001), %str(TRTAN = 1))
In addition to specifying subject numbers, it is also possible to specify summary statistics(mean, std, min, max, and quartiles(min, median, max)) for evaluation items to be set on the Y-axis. (e.g. %str(min > 100 and max < 200))
 - 'Group_var = Set the group variable . (e.g. TRTAN)
 - 'Subject_var = Set the variable representing the Sunject ID. (e.g. SUBJID)
 - 'Value_var = Set the value to display on the Y-axis. (e.g. AVAL)
 - 'Time_var = Set the value to display on the X-axis. (e.g. ADY)
 - 'Xaxis_labelnm = X-axis label name (e.g. %str(Days))
 - 'Yaxis_labelnm = Y-axis label name (e.g. %str(Hemoglobin (g/dL)))
 - 'Xmin = Set the minimum value for the X-axis (e.g. 0)
 - 'Xmax = Set the maximum value for the X-axis (e.g. 200)
 - 'Xinc = Set the increment value for the X-axis (e.g. 50)
 - 'Ymin = Set the minimum value for the Y-axis (e.g. -100)
 - 'Ymax = Set the maximum value for the Y-axis (e.g. 100)
 - 'Yinc = Set the increment value for the Y-axis (e.g. 100)
 - 'Outdir = Figure file output directory
 - 'Fignm = Figure name (e.g. dummy01)
 - 'FIgfmt = Figure format (e.g. PNG)

Example usage:

%highlight_series(Dataset =dummy_testdata02, 
                                            Highlight_Cond = %str(USUBJID = 10001), 
                                            Group_var = TRTAN, 
                                            Subject_var = USUBJID, 
                                            Value_var = AVAL, 
                                            Time_var = ADY, 
                                            Xaxis_labelnm = %str(Days), 
                                            Yaxis_labelnm = %str(Parameter (Unit)), 
                                            Xmin = 0, 
                                            Xmax = 140, 
                                            Xinc = 7, 
                                            Ymin = 175, 
                                            Ymax = 225, 
                                            Yinc = 25, 
                                            Outdir = %str(\\...),  
                                            Fignm = dummy02, 
                                            Figfmt= PDF
                                            );

%highlight_scatter_by_individual() macro

Purpose:

This macro highlights only the plots in the scatter plot that meet specific conditions.  

Parameters:

 - 'Dataset = Input dataset name (e.g. ADLB)
 - 'Highlight_Cond = Set conditions to identify data to be highlighted. (e.g. %str(XVAL > 100 and YVAL > 100))
 - 'Subject_var = Set the variable representing the Sunject ID. (e.g. SUBJID)
 - 'Xaxis_Value_var = Set the value to display on the X-axis. (e.g. XVAL)
 - 'Yaxis_Value_var = Set the value to display on the Y-axis. (e.g. YVAL)
 - 'Xaxis_labelnm = X-axis label name (e.g. %str(Assessment 1))
 - 'Yaxis_labelnm = Y-axis label name (e.g. %str(Assessment 2))
 - 'Xmin = Set the minimum value for the X-axis (e.g. 0)
 - 'Xmax = Set the maximum value for the X-axis (e.g. 200)
 - 'Xinc = Set the increment value for the X-axis (e.g. 50)
 - 'Ymin = Set the minimum value for the Y-axis (e.g. -100)
 - 'Ymax = Set the maximum value for the Y-axis (e.g. 100)
 - 'Yinc = Set the increment value for the Y-axis (e.g. 100)
 - 'X_ref = Set the reference line value for the X-axis (e.g. 100)
 - 'Y_ref = Set the reference line value for the Y-axis (e.g. 100)
 - 'Fig_title = Figure title (e.g. %str(Parameter (Unit)))
 - 'Outdir = Figure file output directory
 - 'Fignm = Figure name (e.g. dummy01)
 - 'FIgfmt = Figure format (e.g. PNG, PDF)

Example usage:

%highlight_scatter_by_individual(Dataset = dummy_TestData03,  
                                      Highlight_Cond = %str(XVAL > 200 and YVAL > 200),
                                      Subject_var = USUBJID, 
                                      Xaxis_Value_var = XVAL, 
                                      Yaxis_Value_var = YVAL, 
                                      Xaxis_labelnm = %str(Assessment 1), 
                                      Yaxis_labelnm = %str(Assessment 2),
                                      Xmin = 0,
                                      Xmax = 300,
                                      Xinc = 100,
                                      Ymin = 0,
                                      Ymax = 300,
                                      Yinc = 100,
                                      X_ref = 200, 
                                      Y_ref = 200,
                                      Outdir = %str(\\...),  
                                      Fig_title = %str(Parameter (Unit)), 
                                      Fignm = dummy03, 
                                      Figfmt= PDF
                                      );

%highlight_scatter_by_group() macro

Purpose:

This macro highlights only the plots by group in the scatter plot that meet specific conditions.  

Parameters:   

 - 'Dataset = Input dataset name (e.g. ADLB)
 - 'Highlight_Cond = Set conditions to identify data to be highlighted. (e.g. %str(XVAL > 100 and YVAL > 100))
 - 'Group_var = Set the group variable. (e.g. TRTAN)
 - 'Subject_var = Set the variable representing the Sunject ID. (e.g. SUBJID)
 - 'Xaxis_Value_var = Set the value to display on the X-axis. (e.g. XVAL)
 - 'Yaxis_Value_var = Set the value to display on the Y-axis. (e.g. YVAL)
 - 'Xaxis_labelnm = X-axis label name (e.g. %str(Assessment 1))
 - 'Yaxis_labelnm = Y-axis label name (e.g. %str(Assessment 2))
 - 'Xmin = Set the minimum value for the X-axis (e.g. 0)
 - 'Xmax = Set the maximum value for the X-axis (e.g. 200)
 - 'Xinc = Set the increment value for the X-axis (e.g. 50)
 - 'Ymin = Set the minimum value for the Y-axis (e.g. -100)
 - 'Ymax = Set the maximum value for the Y-axis (e.g. 100)
 - 'Yinc = Set the increment value for the Y-axis (e.g. 100)
 - 'X_ref = Set the reference line value for the X-axis (e.g. 100)
 - 'Y_ref = Set the reference line value for the Y-axis (e.g. 100)
 - 'Fig_title = Figure title (e.g. %str(Parameter (Unit)))
 - 'Outdir = Figure file output directory
 - 'Fignm = Figure name (e.g. dummy01)
 - 'FIgfmt = Figure format (e.g. PNG, PDF)

Example usage:

%highlight_scatter_by_group(Dataset = dummy_TestData04,  
                                      Highlight_Cond = %str(XVAL > 200 and YVAL > 200),
                                      Group_var = TRTAN, 
                                      Subject_var = USUBJID, 
                                      Xaxis_Value_var = XVAL, 
                                      Yaxis_Value_var = YVAL, 
                                      Xaxis_labelnm = %str(Assessment 1), 
                                      Yaxis_labelnm = %str(Assessment 2),
                                      Xmin = 0,
                                      Xmax = 300,
                                      Xinc = 100,
                                      Ymin = 0,
                                      Ymax = 300,
                                      Yinc = 100,
                                      X_ref = 200, 
                                      Y_ref = 200,
                                      Outdir = %, 
                                      Fig_title = %str(Parameter (Unit)), 
                                      Fignm = dummy04, 
                                      Figfmt= PDF
                                      );

version history

0.0.1(10February2026): Initial version

What is SAS Packages?

The package is built on top of SAS Packages Framework(SPF) developed by Bartosz Jablonski.

For more information about the framework, see SAS Packages Framework.

You can also find more SAS Packages (SASPacs) in the SAS Packages Archive(SASPAC).

How to use SAS Packages? (quick start)

1. Set-up SAS Packages Framework

First, create a directory for your packages and assign a packages fileref to it.

filename packages "\path\to\your\packages";

Secondly, enable the SAS Packages Framework. (If you don't have SAS Packages Framework installed, follow the instruction in SPF documentation to install SAS Packages Framework.)

%include packages(SPFinit.sas)

2. Install SAS package

Install SAS package you want to use with the SPF's %installPackage() macro.

  • For packages located in SAS Packages Archive(SASPAC) run:

    %installPackage(packageName)
  • For packages located in PharmaForest run:

    %installPackage(packageName, mirror=PharmaForest)
  • For packages located at some network location run:

    %installPackage(packageName, sourcePath=https://some/internet/location/for/packages)

    (e.g. %installPackage(ABC, sourcePath=https://github.com/SomeRepo/ABC/raw/main/))

3. Load SAS package

Load SAS package you want to use with the SPF's %loadPackage() macro.

%loadPackage(packageName)

Enjoy!

About

SAS Highlight is a utility package designed to visually highlight data points, subjects, or groups that meet specific conditions in ODS Graphics plots. The package focuses on commonly used exploratory and review graphics in clinical and analytical workflows, especially: - Spaghetti plots - Scatter plots

Resources

License

MIT, MIT licenses found

Licenses found

MIT
LICENSE
MIT
license.sas

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages