BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
PamG
Quartz | Level 8

How do we put a space between the two series?  The box plots are overlapping and is there a way to put some gap between them.  Sample code attached below.

 

data forest_data;
 input Gp $ XValue a1 lowa1 uppera1 a2 lowa2 uppera2;
    datalines;
A 10 0.50 0.30 0.70 0.55 0.40 0.60
B 20 0.25 0.10 0.40 0.70 0.30 0.80
C 30 0.80 0.60 1.00 0.90 0.50 0.80 ; run; proc sgplot data=forest_data; scatter x=XValue y=a1 / yerrorlower=lowa1 yerrorupper=uppera1; scatter x=XValue y=a2 / yerrorlower=lowa2 yerrorupper=uppera2; yaxis label="Odds Ratio" ; run;

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
yabwon
Amethyst | Level 16

Do you mean something like this:

data forest_data;
 input Gp $ XValue a1 lowa1 uppera1 a2 lowa2 uppera2;
  XValue2=XValue+1;
  XValue=XValue-1;
    datalines;
A 10 0.50 0.30 0.70 0.55 0.40 0.60 
B 20 0.25 0.10 0.40 0.70 0.30 0.80 
C 30 0.80 0.60 1.00 0.90 0.50 0.80
;
run;

proc sgplot data=forest_data;
     scatter x=XValue y=a1 / yerrorlower=lowa1 yerrorupper=uppera1;

     scatter x=XValue2 y=a2 / yerrorlower=lowa2 yerrorupper=uppera2;
     
    yaxis label="Odds Ratio" ;
    xaxis min=0 max=40 VALUES=(0 10 20 30 40)
    VALUESDISPLAY=(" " "10" "20" "30" " ")
  ;
run;

yabwon_0-1760110865076.png

 

 

Bart

_______________
Polish SAS Users Group: www.polsug.com and communities.sas.com/polsug

"SAS Packages: the way to share" at SGF2020 Proceedings (the latest version), GitHub Repository, and YouTube Video.
Hands-on-Workshop: "Share your code with SAS Packages"
"My First SAS Package: A How-To" at SGF2021 Proceedings

SAS Ballot Ideas: one: SPF in SAS, two, and three
SAS Documentation



View solution in original post

5 REPLIES 5
yabwon
Amethyst | Level 16

Do you mean something like this:

data forest_data;
 input Gp $ XValue a1 lowa1 uppera1 a2 lowa2 uppera2;
  XValue2=XValue+1;
  XValue=XValue-1;
    datalines;
A 10 0.50 0.30 0.70 0.55 0.40 0.60 
B 20 0.25 0.10 0.40 0.70 0.30 0.80 
C 30 0.80 0.60 1.00 0.90 0.50 0.80
;
run;

proc sgplot data=forest_data;
     scatter x=XValue y=a1 / yerrorlower=lowa1 yerrorupper=uppera1;

     scatter x=XValue2 y=a2 / yerrorlower=lowa2 yerrorupper=uppera2;
     
    yaxis label="Odds Ratio" ;
    xaxis min=0 max=40 VALUES=(0 10 20 30 40)
    VALUESDISPLAY=(" " "10" "20" "30" " ")
  ;
run;

yabwon_0-1760110865076.png

 

 

Bart

_______________
Polish SAS Users Group: www.polsug.com and communities.sas.com/polsug

"SAS Packages: the way to share" at SGF2020 Proceedings (the latest version), GitHub Repository, and YouTube Video.
Hands-on-Workshop: "Share your code with SAS Packages"
"My First SAS Package: A How-To" at SGF2021 Proceedings

SAS Ballot Ideas: one: SPF in SAS, two, and three
SAS Documentation



PamG
Quartz | Level 8
Thanks so much Bart!!!!
DanH_sas
SAS Super FREQ

If the goal is to add space on either end of the axis, you can use OFFSETMIN and OFFSETMAX without having to create unused tick values. Just replace you XAXIS statement with the following (adjust the offset values to taste):

xaxis offsetmin=0.1 offsetmax=0.1;

FreelanceReinh
Jade | Level 19

Alternatively, you could follow Example 2: Clustering a Grouped Scatter Plot from the documentation:

data want;
set forest_data;
series=1; a=a1; lowa=lowa1; uppera=uppera1; output;
series=2; a=a2; lowa=lowa2; uppera=uppera2; output;
drop a1--uppera2;
run;

proc sgplot data=want;
scatter x=XValue y=a / yerrorlower=lowa yerrorupper=uppera
  group=series groupdisplay=cluster clusterwidth=0.15;
yaxis label="Odds Ratio" ;
run;
quickbluefish
Barite | Level 11
Just FYI, the common term for what you're talking about is "jitter", as in, "adding jitter" to the estimates.

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

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
  • 5 replies
  • 129 views
  • 4 likes
  • 5 in conversation