Figure 3: Individual Subject Body Mass Index (BMI) Over Study Day by Treatment Group

ADBMI = BMI analysis dataset (longitudinal; 3 records/subject)

In [1]:
libname sasdata "/export/viya/homes/alpha@alphatraore.com/toydata";
data ADBMI;
    set sasdata.ADBMI;
run;

proc sort data=adbmi; by trt01a subjid ady; run;

proc print data=ADBMI (obs=12); run;

/*proc contents data=adbmi; run;*/
SAS server started using Context SAS Studio compute context with SESSION_ID=2f553f21-1bf7-480d-89c9-0b3c555e899e-ses0000
SAS Output

The SAS System

Obs SUBJID STUDYID USUBJID TRT01A TRT01AN PARAMCD PARAM AVISIT ANL01FL SAFFL ADT ADY AVISITN AVAL BASE ABLFL CHG PCHG
1 1905 STDY-001 STDY-001-1905 1X Combination 1 BMI Body Mass Index (kg/m^2) Baseline Y Y 01JAN2026 0 0 29.0 29 Y 0.0 0.0000
2 1905 STDY-001 STDY-001-1905 1X Combination 1 BMI Body Mass Index (kg/m^2) Week 4 Y Y 29JAN2026 28 4 31.0 29   2.0 6.8966
3 1905 STDY-001 STDY-001-1905 1X Combination 1 BMI Body Mass Index (kg/m^2) Week 8 Y Y 26FEB2026 56 8 30.0 29   1.0 3.4483
4 1913 STDY-001 STDY-001-1913 1X Combination 1 BMI Body Mass Index (kg/m^2) Baseline Y Y 01JAN2026 0 0 30.0 30 Y 0.0 0.0000
5 1913 STDY-001 STDY-001-1913 1X Combination 1 BMI Body Mass Index (kg/m^2) Week 4 Y Y 29JAN2026 28 4 31.5 30   1.5 5.0000
6 1913 STDY-001 STDY-001-1913 1X Combination 1 BMI Body Mass Index (kg/m^2) Week 8 Y Y 26FEB2026 56 8 32.5 30   2.5 8.3333
7 1916 STDY-001 STDY-001-1916 1X Combination 1 BMI Body Mass Index (kg/m^2) Baseline Y Y 01JAN2026 0 0 28.0 28 Y 0.0 0.0000
8 1916 STDY-001 STDY-001-1916 1X Combination 1 BMI Body Mass Index (kg/m^2) Week 4 Y Y 29JAN2026 28 4 31.0 28   3.0 10.7143
9 1916 STDY-001 STDY-001-1916 1X Combination 1 BMI Body Mass Index (kg/m^2) Week 8 Y Y 26FEB2026 56 8 32.0 28   4.0 14.2857
10 1919 STDY-001 STDY-001-1919 1X Combination 1 BMI Body Mass Index (kg/m^2) Baseline Y Y 01JAN2026 0 0 17.0 17 Y 0.0 0.0000
11 1919 STDY-001 STDY-001-1919 1X Combination 1 BMI Body Mass Index (kg/m^2) Week 4 Y Y 29JAN2026 28 4 18.5 17   1.5 8.8235
12 1919 STDY-001 STDY-001-1919 1X Combination 1 BMI Body Mass Index (kg/m^2) Week 8 Y Y 26FEB2026 56 8 17.5 17   0.5 2.9412
In [2]:
/*==================================================================*
 * Figure: Individual Body Mass Index (kg/m^2) Over Time by Treatment
 * 2x2 layout; separate legends per panel
 *=================================================================*/

options nodate nonumber orientation=portrait;
ods graphics on / reset=all imagename="BMINDEX" imagefmt=png;

/*--- OPTIONAL: ensure subjid is character (simplifies attrmap matching) ---*/
data bmi;
  set adbmi;               
run;

proc print data=bmi (obs=5); run;
SAS Output

The SAS System

Obs SUBJID STUDYID USUBJID TRT01A TRT01AN PARAMCD PARAM AVISIT ANL01FL SAFFL ADT ADY AVISITN AVAL BASE ABLFL CHG PCHG
1 1905 STDY-001 STDY-001-1905 1X Combination 1 BMI Body Mass Index (kg/m^2) Baseline Y Y 01JAN2026 0 0 29.0 29 Y 0.0 0.00000
2 1905 STDY-001 STDY-001-1905 1X Combination 1 BMI Body Mass Index (kg/m^2) Week 4 Y Y 29JAN2026 28 4 31.0 29   2.0 6.89655
3 1905 STDY-001 STDY-001-1905 1X Combination 1 BMI Body Mass Index (kg/m^2) Week 8 Y Y 26FEB2026 56 8 30.0 29   1.0 3.44828
4 1913 STDY-001 STDY-001-1913 1X Combination 1 BMI Body Mass Index (kg/m^2) Baseline Y Y 01JAN2026 0 0 30.0 30 Y 0.0 0.00000
5 1913 STDY-001 STDY-001-1913 1X Combination 1 BMI Body Mass Index (kg/m^2) Week 4 Y Y 29JAN2026 28 4 31.5 30   1.5 5.00000
In [3]:
/*--- OPTIONAL: attribute map to control colors/markers (edit as you like) ---*/
data attrmap;
  length id $8 value $20 linecolor markercolor $12 linepattern $12 markersymbol $12;
  id='BMI';
  
  /* Vehicle Control (example IDs from your plot) */
  value='1701'; linecolor='black'; markercolor='black'; linepattern='solid'; markersymbol='asterisk'; output;
  value='1756'; linecolor='blue' ; markercolor='blue' ; linepattern='solid'; markersymbol='circle'  ; output;
  value='1906'; linecolor='green'; markercolor='green'; linepattern='solid'; markersymbol='star'    ; output;
  value='1705'; linecolor='red'  ; markercolor='red'  ; linepattern='solid'; markersymbol='square'  ; output;
  value='1904'; linecolor='magenta'; markercolor='magenta'; linepattern='solid'; markersymbol='triangle'; output;
  value='1915'; linecolor='orange'; markercolor='orange'; linepattern='solid'; markersymbol='diamond'; output;

  /* 1X Combination */
  value='1905'; linecolor='black'; markercolor='black'; linepattern='solid'; markersymbol='asterisk'; output;
  value='1916'; linecolor='blue' ; markercolor='blue' ; linepattern='solid'; markersymbol='circle'  ; output;
  value='1981'; linecolor='green'; markercolor='green'; linepattern='solid'; markersymbol='star'    ; output;
  value='1913'; linecolor='red'  ; markercolor='red'  ; linepattern='solid'; markersymbol='square'  ; output;
  value='1919'; linecolor='magenta'; markercolor='magenta'; linepattern='solid'; markersymbol='triangle'; output;
  value='1984'; linecolor='orange'; markercolor='orange'; linepattern='solid'; markersymbol='diamond'; output;

  /* 3X Combination */
  value='1758'; linecolor='black'; markercolor='black'; linepattern='solid'; markersymbol='asterisk'; output;
  value='1918'; linecolor='blue' ; markercolor='blue' ; linepattern='solid'; markersymbol='circle'  ; output;
  value='1985'; linecolor='green'; markercolor='green'; linepattern='solid'; markersymbol='star'    ; output;
  value='1823'; linecolor='red'  ; markercolor='red'  ; linepattern='solid'; markersymbol='square'  ; output;
  value='1920'; linecolor='magenta'; markercolor='magenta'; linepattern='solid'; markersymbol='triangle'; output;
  value='1989'; linecolor='orange'; markercolor='orange'; linepattern='solid'; markersymbol='diamond'; output;

  /* 5X Combination */
  value='1708'; linecolor='black'; markercolor='black'; linepattern='solid'; markersymbol='asterisk'; output;
  value='1901'; linecolor='blue' ; markercolor='blue' ; linepattern='solid'; markersymbol='circle'  ; output;
  value='1926'; linecolor='green'; markercolor='green'; linepattern='solid'; markersymbol='star'    ; output;
  value='1757'; linecolor='red'  ; markercolor='red'  ; linepattern='solid'; markersymbol='square'  ; output;
  value='1907'; linecolor='magenta'; markercolor='magenta'; linepattern='solid'; markersymbol='triangle'; output;
  value='1988'; linecolor='orange'; markercolor='orange'; linepattern='solid'; markersymbol='diamond'; output;
run;

proc print data=attrmap (obs=5); run;
SAS Output

The SAS System

Obs id value linecolor markercolor linepattern markersymbol
1 BMI 1701 black black solid asterisk
2 BMI 1756 blue blue solid circle
3 BMI 1906 green green solid star
4 BMI 1705 red red solid square
5 BMI 1904 magenta magenta solid triangle
In [4]:
options nonotes nosource nosource2 nomprint nomlogic nosymbolgen;

/*--- Macro to draw one panel (so each panel has its own legend) ---*/
%macro one_panel(trt=, paneltitle=);

proc sgplot data=bmi(where=(TRT01A="&trt")) dattrmap=attrmap noautolegend;
  title "&paneltitle";

  series x=ady y=aval / group=subjid attrid=BMI markers
         lineattrs=(thickness=1) markerattrs=(size=8) name="s";

  xaxis label="Study Day" values=(-4 to 56 by 6) offsetmin=0 offsetmax=0;
  yaxis label="Body Mass Index (kg/m^2)" values=(10 to 50 by 4);

  keylegend "s" / title="Subject" location=outside position=bottom across=3;
run;
title;
%mend;
88   ods listing close;ods html5 (id=saspy_internal) options(bitmap_mode='inline') device=svg style=HTMLBlue; ods graphics on /
88 ! outputfmt=png;
NOTE: Writing HTML5(SASPY_INTERNAL) Body file: sashtml3.htm
89   
90   options nonotes nosource nosource2 nomprint nomlogic nosymbolgen;

In [7]:
ods graphics / reset attrpriority=color;
ods pdf file="BMI_Figure.pdf" style=styles.htmlblue;

/* Overall figure title (prints once, above the whole grid) */
proc odstext;
  p "Figure 3: Individual Subject Body Mass Index (kg/m^2) Over Study Day by Treatment Group"
    / style=[just=center fontweight=bold fontsize=11pt];
run;

ods layout gridded columns=2 rows=2 column_gutter=0.25in row_gutter=0.25in;

ods region; %one_panel(trt=Vehicle Control, paneltitle=Vehicle Control);
ods region; %one_panel(trt=1X Combination, paneltitle=1X Combination);
ods region; %one_panel(trt=3X Combination, paneltitle=3X Combination);
ods region; %one_panel(trt=5X Combination, paneltitle=5X Combination);

ods layout end;
ods pdf close;
SAS Output

Figure 3: Individual Subject Body Mass Index (kg/m^2) Over Study Day by Treatment Group

svgtitle The SGPlot Procedure -4 2 8 14 20 26 32 38 44 50 56 Study Day 10 14 18 22 26 30 34 38 42 46 50 Body Mass Index (kg/m^2) 1915 1906 1904 1756 1705 1701 Subject Vehicle Control The SGPlot Procedure
svgtitle The SGPlot Procedure -4 2 8 14 20 26 32 38 44 50 56 Study Day 10 14 18 22 26 30 34 38 42 46 50 Body Mass Index (kg/m^2) 1984 1981 1919 1916 1913 1905 Subject 1X Combination The SGPlot Procedure
svgtitle The SGPlot Procedure -4 2 8 14 20 26 32 38 44 50 56 Study Day 10 14 18 22 26 30 34 38 42 46 50 Body Mass Index (kg/m^2) 1989 1985 1920 1918 1823 1758 Subject 3X Combination The SGPlot Procedure
svgtitle The SGPlot Procedure -4 2 8 14 20 26 32 38 44 50 56 Study Day 10 14 18 22 26 30 34 38 42 46 50 Body Mass Index (kg/m^2) 1988 1926 1907 1901 1757 1708 Subject 5X Combination The SGPlot Procedure
In [ ]: