Data visualization with SAS programming

swim lane plot for dose changes

Accepted Solution Solved
Reply
New Contributor
Posts: 4
Accepted Solution

swim lane plot for dose changes

[ Edited ]

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.

 


Accepted Solutions
Solution
‎01-18-2018 01:56 PM
SAS Employee
Posts: 1,031

Re: swim lane plot for dose changes

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


All Replies
Super User
Posts: 22,873

Re: swim lane plot for dose changes

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.

 


 

New Contributor
Posts: 4

Re: swim lane plot for dose changes

Hi Reeza,

 

Thanks for your reply.

I have attached the sample data in excel.

I am using PC SAS.

 

Thanks for your help.

Solution
‎01-18-2018 01:56 PM
SAS Employee
Posts: 1,031

Re: swim lane plot for dose changes

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

New Contributor
Posts: 4

Re: swim lane plot for dose changes

Posted in reply to RobertAllison_SAS

Hi Robert,

 

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

 

Thanks,

Kiran

New Contributor
Posts: 4

Re: swim lane plot for dose changes

Posted in reply to RobertAllison_SAS

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

☑ This topic is solved.

Need further help from the community? Please ask a new question.

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