<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic sgplot scatter position of datapoints in Statistical Procedures</title>
    <link>https://communities.sas.com/t5/Statistical-Procedures/sgplot-scatter-position-of-datapoints/m-p/787128#M38585</link>
    <description>&lt;P&gt;Dear all,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am trying to plot the LSMEANS of two DVs, obtained from a PROC GLM.&lt;/P&gt;&lt;P&gt;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.&lt;/P&gt;&lt;P&gt;At present I managed to obtain the graph that I attach with the SGPLOT at the end of the syntax that I am sharing.&lt;/P&gt;&lt;P&gt;There are two issues with that, though.&lt;/P&gt;&lt;P&gt;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.&lt;/P&gt;&lt;P&gt;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?&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I attach the datafile as well.&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Screenshot 2021-12-22 at 16.43.55.png" style="width: 999px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/66932i2FA6CDB2ECA9272F/image-size/large?v=v2&amp;amp;px=999" role="button" title="Screenshot 2021-12-22 at 16.43.55.png" alt="Screenshot 2021-12-22 at 16.43.55.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;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;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Wed, 22 Dec 2021 16:00:22 GMT</pubDate>
    <dc:creator>emaneman</dc:creator>
    <dc:date>2021-12-22T16:00:22Z</dc:date>
    <item>
      <title>sgplot scatter position of datapoints</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/sgplot-scatter-position-of-datapoints/m-p/787128#M38585</link>
      <description>&lt;P&gt;Dear all,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am trying to plot the LSMEANS of two DVs, obtained from a PROC GLM.&lt;/P&gt;&lt;P&gt;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.&lt;/P&gt;&lt;P&gt;At present I managed to obtain the graph that I attach with the SGPLOT at the end of the syntax that I am sharing.&lt;/P&gt;&lt;P&gt;There are two issues with that, though.&lt;/P&gt;&lt;P&gt;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.&lt;/P&gt;&lt;P&gt;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?&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I attach the datafile as well.&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Screenshot 2021-12-22 at 16.43.55.png" style="width: 999px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/66932i2FA6CDB2ECA9272F/image-size/large?v=v2&amp;amp;px=999" role="button" title="Screenshot 2021-12-22 at 16.43.55.png" alt="Screenshot 2021-12-22 at 16.43.55.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;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;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 22 Dec 2021 16:00:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/sgplot-scatter-position-of-datapoints/m-p/787128#M38585</guid>
      <dc:creator>emaneman</dc:creator>
      <dc:date>2021-12-22T16:00:22Z</dc:date>
    </item>
    <item>
      <title>Re: sgplot scatter position of datapoints</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/sgplot-scatter-position-of-datapoints/m-p/787136#M38586</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For your question 2.)&lt;/P&gt;
&lt;P&gt;You can use this option on the SCATTER statement :&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;DIV class="xisDoc-refProc"&gt;
&lt;DIV class="xisDoc-refBlock"&gt;
&lt;DIV class="xisDoc-syntax"&gt;
&lt;DIV class="xisDoc-syntaxDescription"&gt;
&lt;DIV class="xisDoc-optionalArgGroup"&gt;
&lt;DIV id="n0biw9f2tsdjcvn13obxynmemvk8" class="xisDoc-argDescriptionPair"&gt;
&lt;H4 class="xisDoc-argument"&gt;DISCRETEOFFSET=&lt;EM class="xisDoc-userSuppliedValue"&gt;numeric-value&lt;/EM&gt;&lt;/H4&gt;
&lt;DIV class="xisDoc-argumentDescription"&gt;
&lt;P&gt;&lt;SPAN class="xisDoc-shortDescription"&gt;specifies an amount to offset all markers from discrete X or Y values.&lt;/SPAN&gt; &lt;SPAN class="xisDoc-paraSimpleFirst"&gt;Specify a value from -0.5 (left offset) to +0.5 (right offset).&lt;/SPAN&gt;&lt;/P&gt;
&lt;SECTION class="xisDoc-tableWrap"&gt;
&lt;TABLE class="xisDoc-summary"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TH class="xisDoc-summaryDefault"&gt;Default&lt;/TH&gt;
&lt;TD class="xisDoc-summaryText"&gt;0.0 (no offset)&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TH class="xisDoc-requirement"&gt;Requirement&lt;/TH&gt;
&lt;TD class="xisDoc-summaryText"&gt;This option is applicable only when the X or Y axis is discrete.&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;/SECTION&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Regards,&lt;/P&gt;
&lt;P&gt;Koen&lt;/P&gt;</description>
      <pubDate>Wed, 22 Dec 2021 17:13:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/sgplot-scatter-position-of-datapoints/m-p/787136#M38586</guid>
      <dc:creator>sbxkoenk</dc:creator>
      <dc:date>2021-12-22T17:13:31Z</dc:date>
    </item>
    <item>
      <title>Re: sgplot scatter position of datapoints</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/sgplot-scatter-position-of-datapoints/m-p/787143#M38588</link>
      <description>&lt;P&gt;Thanks Koen, this works perfectly.&lt;/P&gt;</description>
      <pubDate>Wed, 22 Dec 2021 17:32:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/sgplot-scatter-position-of-datapoints/m-p/787143#M38588</guid>
      <dc:creator>emaneman</dc:creator>
      <dc:date>2021-12-22T17:32:48Z</dc:date>
    </item>
  </channel>
</rss>

