BookmarkSubscribeRSS Feed
Anita_n
Pyrite | Level 9

Dear all, 

assuming I had this code which plots a sankey chart 

proc sgplot data=myplotdata noborder;
        polygon x=x y=y id=id / fill nooutline group=group transparency=0.3 name='p' label=count labelloc=insidebbox ;
        xaxistable nodes / x=x_label location=inside position=top nolabel title="Sankey Chart" valueattrs=(size=12pt) titleattrs=(size=12pt) ;
        xaxis min=0 max=%sysevalf(100+5) values=(0 to 100 by 10) display=none valueshint;
        yaxis min=0 max=100 reverse values=(0 to 100 by 10) display=none;
        keylegend 'p'/ title=" " noborder location=outside position=bottom exclude=('') valueattrs=(size=12pt) titleattrs=(size=12pt);
    run;

I  am able to label the bar segments with label=count. I will also like to label the nodes leaving the segments (variable=n_move). My question is, is it possible to label using multiple variables (in this case count and n_move) in sgplot?

if yes, how ?

 

Anita_n_0-1683008164026.png

The red arrow indicates label=count  and the blue arrow indicates label=n_move showing the number of patients leaving that group

 

2 REPLIES 2
ballardw
Super User

If you have x, y coordinates associated where you want the label placed a TEXT plot would work.

 

Or provide data so we can run your code and see what might be possible. Sometimes these extra label steps are easy, sometimes you need to add variables or rearrange data a bit.

 

You can try duplicating your plot statement with a the label changed to the other variable. If that obscures your plot too much try turning the transparency up in BOTH ploygon statements as the overlaps will get more saturation.

 

I hope you are making this a relatively large graphic as you are going to have a lot of text floating around, likely with collisions. Are you sure that you want those skinny connections with text?

Anita_n
Pyrite | Level 9

@ballardw Thankyou, I will try that

SAS Innovate 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!

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
  • 2 replies
  • 555 views
  • 0 likes
  • 2 in conversation