Dear all,
I am trying to plot the LSMEANS of two DVs, obtained from a PROC GLM.
The two DVs are on different scales, but i would like to put them on the same graph, with the two yaxes representing the two DVs.
At present I managed to obtain the graph that I attach with the SGPLOT at the end of the syntax that I am sharing.
There are two issues with that, though.
1. I had to recreate a sas datafile with the ods output, to partially transpose the file to a wide format. It can probably be done with the transpose function, but I wonder whether there is a way to plot the two DVs in a manner similar to the attached graph, using the ods output directly, without transformations.
2. As you can see, the values for the two DVs, one in blue and one in red, overlap, making it difficult to read. Is there a way to move them slightly apart from each other?
I attach the datafile as well.
proc glm data = replication2 ;
class Role;
model RMET tom= Role ;
ods output LSMeanCL=be;
lsmeans role /cl;
run; quit;
proc print data=be;
data secondw;
infile datalines delimiter=' ';
input Role$ RMLowerCL RMLSMean RMUpperCL FBLowerCL FBLSMean FBUpperCL;
datalines;
Director 21.359966 23.037037 24.714108 0.252911 0.444444 0.635978
Matcher 21.521751 23.230769 24.939787 0.266357 0.461538 0.65672
Overhearer 24.137864 25.916667 27.695469 0.463515 0.666667 0.869818
;
proc sgplot data=secondw;
scatter x=role y=FBlsmean/ yerrorlower=FBLowerCL yerrorupper=FBuppercl markerattrs=or (symbol=DiamondFilled size=8 color=red);
scatter x=role y=RMlsmean/ y2axis yerrorlower=RMlowercl yerrorupper=RMuppercl markerattrs=or (symbol=circlefilled size=12 color=blue);
xaxis min=10 max=36 ;
x2axis min=0 max=1;
Hello,
For your question 2.)
You can use this option on the SCATTER statement :
specifies an amount to offset all markers from discrete X or Y values. Specify a value from -0.5 (left offset) to +0.5 (right offset).
Default | 0.0 (no offset) |
---|---|
Requirement | This option is applicable only when the X or Y axis is discrete. |
Regards,
Koen
Hello,
For your question 2.)
You can use this option on the SCATTER statement :
specifies an amount to offset all markers from discrete X or Y values. Specify a value from -0.5 (left offset) to +0.5 (right offset).
Default | 0.0 (no offset) |
---|---|
Requirement | This option is applicable only when the X or Y axis is discrete. |
Regards,
Koen
Thanks Koen, this works perfectly.
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
ANOVA, or Analysis Of Variance, is used to compare the averages or means of two or more populations to better understand how they differ. Watch this tutorial for more.
Find more tutorials on the SAS Users YouTube channel.