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;
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;
Bart
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;
Bart
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;
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;
It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.
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.
Ready to level-up your skills? Choose your own adventure.