Data visualization with SAS programming

NEED HELP!!! Spider Plots w/ Proc Template

Accepted Solution Solved
Reply
Occasional Contributor
Posts: 16
Accepted Solution

NEED HELP!!! Spider Plots w/ Proc Template

Hi, I am having trouble using an existing Swimmer Plot program and changing it into a Spider Plot.

 

I'm not familiar with graphs and having trouble changing the y-axis from "one record per subject"  to "% change in lesion size from baseline"

 

Here is the original Swimmer's plot code below:

(I believe I have to change YVAR=_n_.   where "_n_" is the sequence # of each subject. And it's one subject per record).

I created a variable lespct1-lespct6, which is the "lesion percentage change from baseline". 

If I can somehow use that variable instead of "_n_" then I think the graphs should change, no?

 

Thanks in advance!

 

data final;
   set sw;
    YVAR = _n_;


   if ongoing= 1 then do;
      xongo= xtime + 0.25;
   end;
 *  if conrflag = 'Y' then
 *     xconrsp= -0.5 ;
 *  else xconrsp= . ;

  format dstage stage. ;
run;

 

data _null_;
   set final end=last;
   if last then do;
      call symput('viewmax', left(put(_n_,3.)));
      call symput('thickn',  left(put(int(250/_n_),3.)));
   end;
run;

proc print data=final;run;

title;
footnote;


*ODS output, set graph orientation, size, RTF file name;
OPTIONS nodate nonumber orientation=landscape papersize='LETTER' ;
ods graphics on / height=7.5 in width=9.5 in ;
ods listing close;
ods pdf file = "&output\&pgmname..pdf" NOGTITLE NOGFOOTNOTE style=tlout;

 


/*************** Output graphic template***********/
Proc TEMPLATE;
   define STATGRAPH gtl_graph;
   begingraph/BORDER=False;
 
   LAYOUT OVERLAY /
     YAXISOPTS = (DISPLAY=(LABEL) OFFSETMIN=0.1 OFFSETMAX=0.2 LABEL="Subjects Received Drug"
                  LABELATTRS=(FAMILY="Arial" WEIGHT=bold SIZE=11pt)
                  LINEAROPTS= (VIEWMIN=1 viewmax=%eval(&viewmax-3) TICKVALUESEQUENCE=(start=1 end=&viewmax INCREMENT=1)))
     XAXISOPTS = (OFFSETMIN=0.05 OFFSETMAX=0.05 LABEL="Drug Exposure (weeks)"
                  LABELATTRS=(FAMILY="Arial" weight=bold size=11pt) TICKVALUEATTRS=(COLOR=BLACK)
                  LINEAROPTS=(VIEWMIN=0 VIEWMAX=&maxweek TICKVALUESEQUENCE=(START=0 END=&maxweek      INCREMENT=weekint)));

 

              /******** draw swimmer lane bars*******/
 
  * barchart x=YVAR y=XTIME /Group=DSTAGE Name="TYP" BARWIDTH=0.6 BARLABEL=0 stat=sum orient=horizontal;

  VECTORPLOT  X=XTIME Y=yvar XORIGIN=0 YORIGIN=yvar/GROUP=DSTAGE
  DATATRANSPARENCY=0.4 ARROWHEADS=FALSE LINEATTRS=(PATTERN=1 THICKNESS=7 );
  SCATTERPLOT  X=eval(XTIME+999) Y=yvar/GROUP=DSTAGE  Name="TYP" DATATRANSPARENCY=0.3 MARKERATTRS=(SYMBOL=squarefilled SIZE=9) ;

 

etc....


Accepted Solutions
Solution
‎10-24-2016 06:06 PM
SAS Super FREQ
Posts: 1,171

Re: NEED HELP!!! Spider Plots w/ Proc Template

Posted in reply to HitmonTran

Your data appears quite complicated.  Here is a simple example on how to create such a Spider plot.

http://blogs.sas.com/content/graphicallyspeaking/2016/10/24/clinical-graphs-spider-plot/

 

View solution in original post


All Replies
SAS Super FREQ
Posts: 1,171

Re: NEED HELP!!! Spider Plots w/ Proc Template

Posted in reply to HitmonTran

What is a "Spider Plot" supposed to look like?  Google shows some Radar Plots.  Is that what you want?  Please share some example images, and you full code with data so we can run the program and see what is happening.  Also, what Version of SAS are you using?

Occasional Contributor
Posts: 16

Re: NEED HELP!!! Spider Plots w/ Proc Template

Posted in reply to Sanjay_SAS

The happy faces in the code is suppose to be a ": )"

SAS Super FREQ
Posts: 1,171

Re: NEED HELP!!! Spider Plots w/ Proc Template

Posted in reply to HitmonTran

just running your data steps, fixed some typos.  However, macro variable &crdte is not found in:

xtime = round((min("&crdte"d, datepart(eosdat), datepart(eotdat)) - ex1dt)/7,0.1);

 

Occasional Contributor
Posts: 16

Re: NEED HELP!!! Spider Plots w/ Proc Template

Posted in reply to Sanjay_SAS
&crdte can be replaced with today's date : '21OCT2016'd. thanks!

xtime = round((min('21OCT2016'd, datepart(eosdat), datepart(eotdat)) - ex1dt)/7,0.1);
Solution
‎10-24-2016 06:06 PM
SAS Super FREQ
Posts: 1,171

Re: NEED HELP!!! Spider Plots w/ Proc Template

Posted in reply to HitmonTran

Your data appears quite complicated.  Here is a simple example on how to create such a Spider plot.

http://blogs.sas.com/content/graphicallyspeaking/2016/10/24/clinical-graphs-spider-plot/

 

Occasional Contributor
Posts: 16

Re: NEED HELP!!! Spider Plots w/ Proc Template

Posted in reply to Sanjay_SAS
so it looks like I I need to manipulate my data from one record per subject to multiple records per subject with one variable for "% change from baseline"?
SAS Super FREQ
Posts: 1,171

Re: NEED HELP!!! Spider Plots w/ Proc Template

Posted in reply to HitmonTran

You want to display the tumor size change from baseline for each subject over time.  This is called a SERIES plot, and needs multiple observations with (x,y) data, that are connected by line segments.  When you have multiple series in the data, you need a curve id (Group) which can be the Subject column.  Now, since you want to color each line by the response group classification (Complete Response, etc), you need to provide that classification as a separate option called GroupLC.  This idea is also sometimes also referred to as a "Speghetti Plot", 

Occasional Contributor
Posts: 16

Re: NEED HELP!!! Spider Plots w/ Proc Template

Posted in reply to Sanjay_SAS

Is there a way to change the color of the swimmer lanes?

And is there a way to add a second title to the legend outside the graphs?

☑ This topic is solved.

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

Discussion stats
  • 8 replies
  • 658 views
  • 2 likes
  • 2 in conversation