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-2024.png

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.

 

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.

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