<?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: how to plot multiple data on same graph in Graphics Programming</title>
    <link>https://communities.sas.com/t5/Graphics-Programming/how-to-plot-multiple-data-on-same-graph/m-p/392667#M13463</link>
    <description>&lt;P&gt;I'm just doing a scatterplot with a line. &amp;nbsp;&lt;/P&gt;&lt;P&gt;Dataset one example:&lt;/P&gt;&lt;P&gt;year &amp;nbsp; &amp;nbsp; &amp;nbsp; Species &amp;nbsp; &amp;nbsp; &amp;nbsp;Number of Observations&lt;/P&gt;&lt;P&gt;1999 &amp;nbsp; &amp;nbsp; &amp;nbsp;622 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 20&lt;/P&gt;&lt;P&gt;1999 &amp;nbsp; &amp;nbsp; &amp;nbsp;597 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 32&lt;/P&gt;&lt;P&gt;2000 &amp;nbsp; &amp;nbsp; &amp;nbsp;597 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 45&lt;/P&gt;&lt;P&gt;2000 &amp;nbsp; &amp;nbsp; &amp;nbsp;596 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 3&lt;/P&gt;&lt;P&gt;2001 &amp;nbsp; &amp;nbsp; &amp;nbsp;622 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 16&lt;/P&gt;&lt;P&gt;....etc... &amp;nbsp;I have 3 species and I want 3 different lines of observations..i'm plotting years vs. # of obs.&lt;/P&gt;&lt;P&gt;My second dataset is simple as well:&lt;/P&gt;&lt;P&gt;Year &amp;nbsp; &amp;nbsp; &amp;nbsp; Av. Winter SST in celsius&amp;nbsp;&lt;/P&gt;&lt;P&gt;1999 &amp;nbsp; &amp;nbsp; &amp;nbsp;8.6&lt;/P&gt;&lt;P&gt;2000 &amp;nbsp; &amp;nbsp; &amp;nbsp;8.8&lt;/P&gt;&lt;P&gt;2001 &amp;nbsp; &amp;nbsp; &amp;nbsp;8.9&lt;/P&gt;&lt;P&gt;...etc...plotting year vs. temperature&lt;/P&gt;&lt;P&gt;So I want 3 species in separate lines, and one temperature line (so two different Y axis). &amp;nbsp;I'm super new to this program so bear with me.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 01 Sep 2017 20:22:50 GMT</pubDate>
    <dc:creator>jswinford</dc:creator>
    <dc:date>2017-09-01T20:22:50Z</dc:date>
    <item>
      <title>how to plot multiple data on same graph</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/how-to-plot-multiple-data-on-same-graph/m-p/392588#M13453</link>
      <description>&lt;P&gt;I want to plot two datasets on the same graph. &amp;nbsp;They are from 2 different SAS files and have two different units, so I can't use group=var to do it. &amp;nbsp;&lt;/P&gt;&lt;P&gt;I know there is an ODS command that will lay datasets on top of one another on one graph,&amp;nbsp;but I can't seem to find the code anywhere.&lt;/P&gt;</description>
      <pubDate>Fri, 01 Sep 2017 16:15:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/how-to-plot-multiple-data-on-same-graph/m-p/392588#M13453</guid>
      <dc:creator>jswinford</dc:creator>
      <dc:date>2017-09-01T16:15:48Z</dc:date>
    </item>
    <item>
      <title>Re: how to plot multiple data on same graph</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/how-to-plot-multiple-data-on-same-graph/m-p/392599#M13456</link>
      <description>&lt;P&gt;A single graphic procedure will only use one data set for the graph created. There are helper data sets that can be used to set attributes for things like line color or markers to make group variables appear consistent.&lt;/P&gt;
&lt;P&gt;You can overlay to different graphs from the same data such as a series and scatter plot in the same SGPLOT call but they will use the same data.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Likely you best bet is to combine the two data sets with a variable to indicate which set the data comes from and possibly use that variable as a Group variable.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;A bit more concrete details such as type of graph(s) and example data would help if you want more specific suggestions.&lt;/P&gt;</description>
      <pubDate>Fri, 01 Sep 2017 17:17:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/how-to-plot-multiple-data-on-same-graph/m-p/392599#M13456</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2017-09-01T17:17:27Z</dc:date>
    </item>
    <item>
      <title>Re: how to plot multiple data on same graph</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/how-to-plot-multiple-data-on-same-graph/m-p/392667#M13463</link>
      <description>&lt;P&gt;I'm just doing a scatterplot with a line. &amp;nbsp;&lt;/P&gt;&lt;P&gt;Dataset one example:&lt;/P&gt;&lt;P&gt;year &amp;nbsp; &amp;nbsp; &amp;nbsp; Species &amp;nbsp; &amp;nbsp; &amp;nbsp;Number of Observations&lt;/P&gt;&lt;P&gt;1999 &amp;nbsp; &amp;nbsp; &amp;nbsp;622 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 20&lt;/P&gt;&lt;P&gt;1999 &amp;nbsp; &amp;nbsp; &amp;nbsp;597 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 32&lt;/P&gt;&lt;P&gt;2000 &amp;nbsp; &amp;nbsp; &amp;nbsp;597 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 45&lt;/P&gt;&lt;P&gt;2000 &amp;nbsp; &amp;nbsp; &amp;nbsp;596 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 3&lt;/P&gt;&lt;P&gt;2001 &amp;nbsp; &amp;nbsp; &amp;nbsp;622 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 16&lt;/P&gt;&lt;P&gt;....etc... &amp;nbsp;I have 3 species and I want 3 different lines of observations..i'm plotting years vs. # of obs.&lt;/P&gt;&lt;P&gt;My second dataset is simple as well:&lt;/P&gt;&lt;P&gt;Year &amp;nbsp; &amp;nbsp; &amp;nbsp; Av. Winter SST in celsius&amp;nbsp;&lt;/P&gt;&lt;P&gt;1999 &amp;nbsp; &amp;nbsp; &amp;nbsp;8.6&lt;/P&gt;&lt;P&gt;2000 &amp;nbsp; &amp;nbsp; &amp;nbsp;8.8&lt;/P&gt;&lt;P&gt;2001 &amp;nbsp; &amp;nbsp; &amp;nbsp;8.9&lt;/P&gt;&lt;P&gt;...etc...plotting year vs. temperature&lt;/P&gt;&lt;P&gt;So I want 3 species in separate lines, and one temperature line (so two different Y axis). &amp;nbsp;I'm super new to this program so bear with me.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 01 Sep 2017 20:22:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/how-to-plot-multiple-data-on-same-graph/m-p/392667#M13463</guid>
      <dc:creator>jswinford</dc:creator>
      <dc:date>2017-09-01T20:22:50Z</dc:date>
    </item>
    <item>
      <title>Re: how to plot multiple data on same graph</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/how-to-plot-multiple-data-on-same-graph/m-p/392682#M13467</link>
      <description>&lt;P&gt;Your example data has too few records and causes some appearance difficulties because of that, especiall with species 596 only appearing once. So I have faked up some additional data. Also not how the data is presented as data step.&lt;/P&gt;
&lt;P&gt;If this were my project I would likely have a format to display a species name instead of the code unless that coding scheme is extremely well know to others or is intended for anonymity.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;data one;
   input Year Species      Number;
   label Number = 'Number of observations';
datalines;
1999      622             20
1999      597             32
1999      596             1
2000      622             18
2000      597             25
2000      596             3
2001      622             29
2001      597             17
2001      596             0
2002      622             22
2002      597             24
2002      596             2
2003      622             33
2003      597             31
2003      596             1
;
run;

data two;
   input Year temp;
   label temp = 'Mean Winter SST (C)';
datalines;
1999      8.6
2000      8.8
2001      8.9
2002      8.2
2003      8.7
;
run;

data combined;
   merge  two one;
   by year;
run;

proc sgplot data=combined;
   series x=year y=Number/group=species 
                        name='Species'
                        lineattrs=(thickness=2)
   ;
   series x=year y=temp/ y2axis 
                         name='temp'
                         lineattrs=(pattern=shortdashdot) 
   ;
   keylegend 'Species' / noborder title='Species code' ;
   format year f4.0;
   y2axis values=(5 to 10 by 1);
run;&lt;/PRE&gt;
&lt;P&gt;The combined set is not ideal for some uses but provides an idea.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 01 Sep 2017 21:03:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/how-to-plot-multiple-data-on-same-graph/m-p/392682#M13467</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2017-09-01T21:03:15Z</dc:date>
    </item>
    <item>
      <title>Re: how to plot multiple data on same graph</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/how-to-plot-multiple-data-on-same-graph/m-p/392683#M13468</link>
      <description>&lt;P&gt;It should go like this:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data obs;
input year species obs;
datalines;
1999      622             20
1999      597             32
2000      597             45
2000      596             3
2001      622             16
;

data temps;
input year temp;
datalines;
1999      8.6
2000      8.8
2001      8.9
;

data graph;
merge obs temps; by year;
run;

proc sgplot data=graph;
series x=year y=obs / group=species markers;
series x=year y=temp / y2axis;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 01 Sep 2017 21:04:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/how-to-plot-multiple-data-on-same-graph/m-p/392683#M13468</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2017-09-01T21:04:36Z</dc:date>
    </item>
  </channel>
</rss>

