<?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 Re: Plot multiple y measures with one x measure in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Plot-multiple-y-measures-with-one-x-measure/m-p/809203#M319084</link>
    <description>&lt;P&gt;It &lt;STRONG&gt;really helps&lt;/STRONG&gt; when you claim something doesn't work if you 1) show the code you tried and 2) describe why it didn't meet your needs.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Sgplot, one way&lt;/P&gt;
&lt;PRE&gt;proc sgplot data=have noautolegend;
   scatter y=m1 x=mean/markerattrs=(symbol=circlefilled color=blue);&lt;BR /&gt;   scatter y=m2 x=mean/markerattrs=(symbol=circlefilled color=blue);&lt;BR /&gt;   scatter y=m3 x=mean/markerattrs=(symbol=circlefilled color=blue);&lt;BR /&gt;   scatter y=m4 x=mean/markerattrs=(symbol=circlefilled color=blue);&lt;BR /&gt;   xaxis label='Horizontal Label';
   yaxis label='Vertical Label';
run;&lt;/PRE&gt;
&lt;P&gt;If you do not specify a symbol then each individual scatter will use a different symbol by default (until it runs out of default settings anyway) and if you don't specify a color each plot will have a different color. Without the Noautolegend to suppress the legend each of the marker symbol/colors would have legend entry.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Or possibly (which is likely more flexible in term of multiple measures)&lt;/P&gt;
&lt;PRE&gt;data have;
   input ID m1 m2 m3 m4 mean;
datalines;
1   5     6    2    1     4
2   2     1    1   0      1
3   9     .    8    7      8
4   2     .    .     2      2 
;

proc transpose data=have out=trans;
   by id mean;
   var m1-m4;
run;

proc sgplot data=trans;
   scatter x=mean y=col1/group=_name_;
   label _name_='Measure';
   xaxis label='Horizontal Label';
   yaxis label='Vertical Label';

run;&lt;/PRE&gt;</description>
    <pubDate>Fri, 22 Apr 2022 05:57:25 GMT</pubDate>
    <dc:creator>ballardw</dc:creator>
    <dc:date>2022-04-22T05:57:25Z</dc:date>
    <item>
      <title>Plot multiple y measures with one x measure</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Plot-multiple-y-measures-with-one-x-measure/m-p/809198#M319080</link>
      <description>&lt;P&gt;This is a sample of my data - Basically, I have multiple measures for each patient, and a calculated mean of those measures. How do I create a scatterplot of the measured values (y) vs the mean value (x) of each patient in one graph? It seems pretty simple, but I have used sgplot and gplot and am stumped!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;ID m1 m2 m3 m4 mean&lt;/P&gt;
&lt;P&gt;1&amp;nbsp; &amp;nbsp;5&amp;nbsp; &amp;nbsp; &amp;nbsp;6&amp;nbsp; &amp;nbsp; 2&amp;nbsp; &amp;nbsp; 1&amp;nbsp; &amp;nbsp; &amp;nbsp;4&lt;/P&gt;
&lt;P&gt;2&amp;nbsp; &amp;nbsp;2&amp;nbsp; &amp;nbsp; &amp;nbsp;1&amp;nbsp; &amp;nbsp; 1&amp;nbsp; &amp;nbsp;0&amp;nbsp; &amp;nbsp; &amp;nbsp; 1&lt;/P&gt;
&lt;P&gt;3&amp;nbsp; &amp;nbsp;9&amp;nbsp; &amp;nbsp; &amp;nbsp;.&amp;nbsp; &amp;nbsp; 8&amp;nbsp; &amp;nbsp; 7&amp;nbsp; &amp;nbsp; &amp;nbsp; 8&lt;/P&gt;
&lt;P&gt;4&amp;nbsp; &amp;nbsp;2&amp;nbsp; &amp;nbsp; &amp;nbsp;.&amp;nbsp; &amp;nbsp; .&amp;nbsp; &amp;nbsp; &amp;nbsp;2&amp;nbsp; &amp;nbsp; &amp;nbsp; 2&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This is the type of plot I would like to create:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Abishekaa_0-1650600237128.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/70703i26D666F561299D0F/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Abishekaa_0-1650600237128.png" alt="Abishekaa_0-1650600237128.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 22 Apr 2022 04:04:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Plot-multiple-y-measures-with-one-x-measure/m-p/809198#M319080</guid>
      <dc:creator>Abishekaa</dc:creator>
      <dc:date>2022-04-22T04:04:26Z</dc:date>
    </item>
    <item>
      <title>Re: Plot multiple y measures with one x measure</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Plot-multiple-y-measures-with-one-x-measure/m-p/809203#M319084</link>
      <description>&lt;P&gt;It &lt;STRONG&gt;really helps&lt;/STRONG&gt; when you claim something doesn't work if you 1) show the code you tried and 2) describe why it didn't meet your needs.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Sgplot, one way&lt;/P&gt;
&lt;PRE&gt;proc sgplot data=have noautolegend;
   scatter y=m1 x=mean/markerattrs=(symbol=circlefilled color=blue);&lt;BR /&gt;   scatter y=m2 x=mean/markerattrs=(symbol=circlefilled color=blue);&lt;BR /&gt;   scatter y=m3 x=mean/markerattrs=(symbol=circlefilled color=blue);&lt;BR /&gt;   scatter y=m4 x=mean/markerattrs=(symbol=circlefilled color=blue);&lt;BR /&gt;   xaxis label='Horizontal Label';
   yaxis label='Vertical Label';
run;&lt;/PRE&gt;
&lt;P&gt;If you do not specify a symbol then each individual scatter will use a different symbol by default (until it runs out of default settings anyway) and if you don't specify a color each plot will have a different color. Without the Noautolegend to suppress the legend each of the marker symbol/colors would have legend entry.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Or possibly (which is likely more flexible in term of multiple measures)&lt;/P&gt;
&lt;PRE&gt;data have;
   input ID m1 m2 m3 m4 mean;
datalines;
1   5     6    2    1     4
2   2     1    1   0      1
3   9     .    8    7      8
4   2     .    .     2      2 
;

proc transpose data=have out=trans;
   by id mean;
   var m1-m4;
run;

proc sgplot data=trans;
   scatter x=mean y=col1/group=_name_;
   label _name_='Measure';
   xaxis label='Horizontal Label';
   yaxis label='Vertical Label';

run;&lt;/PRE&gt;</description>
      <pubDate>Fri, 22 Apr 2022 05:57:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Plot-multiple-y-measures-with-one-x-measure/m-p/809203#M319084</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2022-04-22T05:57:25Z</dc:date>
    </item>
    <item>
      <title>Re: Plot multiple y measures with one x measure</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Plot-multiple-y-measures-with-one-x-measure/m-p/809282#M319120</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
   input ID m1 m2 m3 m4 mean;
datalines;
1   5     6    2    1     4
2   2     1    1   0      1
3   9     .    8    7      8
4   2     .    .     2      2 
;

proc transpose data=have out=trans;
   by id ;
   var m1-m4 mean;
run;
data trans;
 set trans;
 if _name_='mean' then group=1;
  else group=2;
run;
ods graphics /attrpriority=none;
proc sgplot data=trans noautolegend;
styleattrs datasymbols=( circle star);
   scatter x=id y=col1/group=group datalabel=_name_ markerattrs=(size=20);
   label _name_='Measure';
   xaxis label='Horizontal Label' type=discrete integer;
   yaxis label='Vertical Label';

run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 22 Apr 2022 12:45:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Plot-multiple-y-measures-with-one-x-measure/m-p/809282#M319120</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2022-04-22T12:45:21Z</dc:date>
    </item>
  </channel>
</rss>

