I'm trying to create a "dumbbell" graph in which lines for different y-values run horizontal and begin/end in large circles with numerical x-values.
I'm using SAS 9.4 and have tried 2 different types of graphical overlays - both have the issue that I can't figure out how to center the text in the "dumbbells" (circles) at the beginning and end of the lines. I'm including a pdf of the graphs I created (I'm not worried about colors, etc. at this point). Here is my code (slightly simplified):
title1 'Attempt #1';
data sx;
input sx value lohi $;
datalines;
1 50 lo
1 75 hi
2 10 lo
2 60 hi
3 2 lo
3 30 hi
;
run;
proc sgplot data=sx;
series x=value y=sx / group=sx;
scatter x=value y=sx / group=lohi markerattrs=(size=30) datalabelattrs=(color=black) datalabelpos=center;
run;
title1 'Attempt #2';
data sxlohi;
input sx lo hi;
datalines;
1 50 75
2 10 60
3 2 30
;
run;
proc sgplot data=sxlohi;
scatter x=lo y=sx / markerattrs=(size=30);
scatter x=hi y=sx / markerattrs=(size=30);
highlow y=sx low=lo high=hi / lowlabel=lo highlabel=hi;
run;
Is there a simpler way to make "dumbbell" graphs? Or a way to tweak this code?
Any thoughts would be appreciated! Thanks!
See the example about halfway down the article "Compute a weighted mean",
The example uses the BUBBLE statement for the circles (but scatter should work, too)
and uses the TEXT statement with the STRIP option.
See the example about halfway down the article "Compute a weighted mean",
The example uses the BUBBLE statement for the circles (but scatter should work, too)
and uses the TEXT statement with the STRIP option.
Don't miss out on SAS Innovate - Register now for the FREE Livestream!
Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.
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.