BookmarkSubscribeRSS Feed
_Hopper
Obsidian | Level 7

I'm trying to make something like a swimmer plot, but some of the arrows go in the negative direction. HighLow cannot be used this way correct? What are my options? In this case I have a baseline score and sometimes the score declines so the arrow will point in the negative direction while most are positive.

 

Y-axis variable = Subject Identifier

X-axis variable = 2 score columns one with the baseline value and one with the value at the target timepoint.

 

As a further wrinkle, I would like to place a reference line between groups of subjects on the y-axis.

5 REPLIES 5
ballardw
Super User

Data is helpful if you want working code.

 

A Vector plot should work.

The x=value and y=subject values are the coordinates of the end of the plot. Add Xorigin (base), yorigin the same as y.

Probably use Arrowdirection=out to have a point at the ending value.

_Hopper
Obsidian | Level 7

Data:

 

Subjid TRTAN BASE AVAL

A1            1            12         14

A2            1            10        8

B1           2            11          11

B2           2           10          13

 

I would like to have a divider between treatment groups on the y-axis if it's possible to do.

 

ballardw
Super User

What role does TRTAN play? Nothing was mentioned in the original post about this.

Vector plots require numeric values. So this creates a value of the line number, then create a custom format to display the text of the subjid original value. That numeric requirement may make it much easier to place useful reference lines, maybe not. You didn't provide a description of how to separate the values so I made a guess. Refline can use variables in the data set for the line  location value and label text if you want many reference lines. So it might be that adding some additional variables would be useful.

 

You might use the TRTAN variable as a GROUP variable to indicate membership in a group, if that is the purpose, instead of a separation line.

 

data have;
   input Subjid $ TRTAN $ BASE AVAL;
   yval=_n_;
datalines;
A1            1            12         14
A2            1            10        8
B1           2            11          11
B2           2           10          13
;

proc format library=work;
value yval
1='A1' 
2='A2' 
3='B1' 
4='B2'
;
run;


proc sgplot data=have;
   vector x=aval y=yval / xorigin=base yorigin=yval 
          arrowdirection=out  lineattrs=(thickness=10)
   ;
   format yval yval.;
   refline 2.5 / axis=y  label='Some text label';
   yaxis label='Subject' values=(1 to 4);
   label aval='Some description';
run;
_Hopper
Obsidian | Level 7

TRTAN indicates which treatment the subject received in the dummy dataset.

Data were requested...data provided.

Ksharp
Super User

https://blogs.sas.com/content/graphicallyspeaking/2014/06/22/swimmer-plot/

https://blogs.sas.com/content/graphicallyspeaking/2018/05/13/a-combined-waterfall-and-swimmer-plot/

https://blogs.sas.com/content/graphicallyspeaking/2018/11/16/waterfall-graph-with-more-data-for-subj...

And better post a picture to illustate what you are looking for.

Don't let me to guess what you want.

 

And you can switch these two values manually from low to high to show the right output.

data have;
input Subjid $ TRTAN BASE AVAL;
cards;
A1            1            12         14
A2            1            8        10
B1           2            11          11
B2           2           10          13
;

proc sgplot data=have;
highlow y=Subjid low=base high=aval/type=bar group=trtan;
refline 'A2'/discreteoffset=0.5;
run;

Ksharp_0-1726536335456.png

 

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 5 replies
  • 555 views
  • 1 like
  • 3 in conversation