BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
knitistician
Calcite | Level 5

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!

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
Rick_SAS
SAS Super FREQ

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.

 

 

View solution in original post

2 REPLIES 2
Rick_SAS
SAS Super FREQ

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.

 

 

knitistician
Calcite | Level 5
That worked - thank you!

sas-innovate-white.png

Missed SAS Innovate in Orlando?

Catch the best of SAS Innovate 2025 — anytime, anywhere. Stream powerful keynotes, real-world demos, and game-changing insights from the world’s leading data and AI minds.

 

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