BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
kiransas
Calcite | Level 5

Hi,

 

I am trying to do swim lane plot for dose changes , find attached shell for reference, is there a direct way to get this graph,please help!

I found reference graphs for response but entire graph has bars in same dimensions.

 

1 ACCEPTED SOLUTION

Accepted Solutions
GraphGuy
Meteorite | Level 14

For a custom plot like this, one way to do it would be to start with a blank set of axes, and then programmatically 'draw' the swim lanes in.

 

Here's some code that might get you started:

 

%let name=swim_lane_plot;
filename odsout '.';

PROC IMPORT OUT=my_data DATAFILE="Sample_data_updated.xls" DBMS=EXCEL REPLACE;
 RANGE="Sample_sas"; 
 GETNAMES=YES;
 MIXED=NO;
RUN;

proc sort data=my_data out=my_data;
by SUBJID acn1;
run;

%let scaler=.3;

data anno_lines; set my_data;
by SUBJID;
length function $8 color $12;
xsys='2'; ysys='2'; hsys='3'; when='a';
retain x level;
yc=SUBJID;
if first.SUBJID then do;
 level=0;
 x=0; function='move'; 
 output;
 end;
if acn='Initial Dose Level' then do;
 flag='Initial';
 x=x+duration;
 level=3;
 color='gray11';
 function='draw'; size=level*&scaler; 
 output;
 end;
if acn='Dose Reduced by 1 level' then do;
 x=x+duration;
 level=level-1;
 if level=2 then color='gray77';
 if level=1 then color='graybb';
 function='draw'; size=level*&scaler; 
 output;
 end;
if acn='dose increase' then do;
 x=x+duration;
 level=level+1;
 if level>=3 then color='gray11';
 if level=2 then color='gray77';
 if level=1 then color='graybb';
 function='draw'; size=level*&scaler; 
 output;
 end;
if acn='Dose pause' then do;
 x=x+duration;
 function='draw'; size=.01; color='gray11'; 
 output;
 end;
if acn='Discontinuation' then do;
 x=x+duration;
 function='label'; position='5'; text='X'; color='gray11'; 
 output;
 end;
run;


goptions device=png;
goptions xpixels=700 ypixels=1100;
goptions noborder;

ODS LISTING CLOSE;
ODS HTML path=odsout body="&name..htm" (title="Swim Lane Plot") style=sasweb;

goptions gunit=pct htitle=14pt ftitle="albany amt/bold" htext=10pt ftext="albany amt";
goptions ctext=gray33;

axis1 label=('Patient') major=none minor=none;

axis2 label=('Study Day') order=(0 to 250 by 50) minor=none offset=(0,0);

/* make the plot markers invisible (you'll be annotating the lines) */
symbol1 value=point interpol=none color=black;

title1 ls=1.5 "Custom Swim Lane Plot";

proc gplot data=my_data anno=anno_lines;
plot SUBJID*duration / 
 vaxis=axis1 haxis=axis2
 des='' name="&name";
run;

quit;
ODS HTML CLOSE;
ODS LISTING;

 

swim_lane_plot.png

View solution in original post

5 REPLIES 5
Reeza
Super User

Direct way? No. Is it possible, yes. You would need to post sample data at minimum if you want some help getting this done. 

 

You can look at the SGPLOT procedures for starters.

 

Note that when I say No, that's assuming you're not using SAS Clinical which may have automated reports (I have no idea) and are assuming you're using SAS EG/Studio/Base


@kiransas wrote:

Hi,

 

I am trying to do swim lane plot for dose changes , find attached shell for reference, is there a direct way to get this graph,please help!

I found reference graphs for response but entire graph has bars in same dimensions.

 


 

kiransas
Calcite | Level 5

Hi Reeza,

 

Thanks for your reply.

I have attached the sample data in excel.

I am using PC SAS.

 

Thanks for your help.

GraphGuy
Meteorite | Level 14

For a custom plot like this, one way to do it would be to start with a blank set of axes, and then programmatically 'draw' the swim lanes in.

 

Here's some code that might get you started:

 

%let name=swim_lane_plot;
filename odsout '.';

PROC IMPORT OUT=my_data DATAFILE="Sample_data_updated.xls" DBMS=EXCEL REPLACE;
 RANGE="Sample_sas"; 
 GETNAMES=YES;
 MIXED=NO;
RUN;

proc sort data=my_data out=my_data;
by SUBJID acn1;
run;

%let scaler=.3;

data anno_lines; set my_data;
by SUBJID;
length function $8 color $12;
xsys='2'; ysys='2'; hsys='3'; when='a';
retain x level;
yc=SUBJID;
if first.SUBJID then do;
 level=0;
 x=0; function='move'; 
 output;
 end;
if acn='Initial Dose Level' then do;
 flag='Initial';
 x=x+duration;
 level=3;
 color='gray11';
 function='draw'; size=level*&scaler; 
 output;
 end;
if acn='Dose Reduced by 1 level' then do;
 x=x+duration;
 level=level-1;
 if level=2 then color='gray77';
 if level=1 then color='graybb';
 function='draw'; size=level*&scaler; 
 output;
 end;
if acn='dose increase' then do;
 x=x+duration;
 level=level+1;
 if level>=3 then color='gray11';
 if level=2 then color='gray77';
 if level=1 then color='graybb';
 function='draw'; size=level*&scaler; 
 output;
 end;
if acn='Dose pause' then do;
 x=x+duration;
 function='draw'; size=.01; color='gray11'; 
 output;
 end;
if acn='Discontinuation' then do;
 x=x+duration;
 function='label'; position='5'; text='X'; color='gray11'; 
 output;
 end;
run;


goptions device=png;
goptions xpixels=700 ypixels=1100;
goptions noborder;

ODS LISTING CLOSE;
ODS HTML path=odsout body="&name..htm" (title="Swim Lane Plot") style=sasweb;

goptions gunit=pct htitle=14pt ftitle="albany amt/bold" htext=10pt ftext="albany amt";
goptions ctext=gray33;

axis1 label=('Patient') major=none minor=none;

axis2 label=('Study Day') order=(0 to 250 by 50) minor=none offset=(0,0);

/* make the plot markers invisible (you'll be annotating the lines) */
symbol1 value=point interpol=none color=black;

title1 ls=1.5 "Custom Swim Lane Plot";

proc gplot data=my_data anno=anno_lines;
plot SUBJID*duration / 
 vaxis=axis1 haxis=axis2
 des='' name="&name";
run;

quit;
ODS HTML CLOSE;
ODS LISTING;

 

swim_lane_plot.png

kiransas
Calcite | Level 5

Hi Robert,

 

Thank you  much for the help.I highly appreciate it.

 

Thanks,

Kiran

kiransas
Calcite | Level 5

Really appreciate the code provided, perfect for my current request. Thank you!

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 5 replies
  • 2151 views
  • 0 likes
  • 3 in conversation