<?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: SGPLOT - Series grouped by year in Graphics Programming</title>
    <link>https://communities.sas.com/t5/Graphics-Programming/SGPLOT-Series-grouped-by-year/m-p/421329#M14495</link>
    <description>&lt;P&gt;Welcome to the SAS forums. Note that I've moved your post to the graphics board as it's more related.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Regarding your question, I would suggest the following approach:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;1. Use a WHERE clause to filter the data.&lt;/P&gt;
&lt;P&gt;2. Create new variables month &amp;amp; year that will reflect the month and year&lt;/P&gt;
&lt;P&gt;3. Same code with the WHERE filter and then use GROUP=YEAR and month as date instead.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You'll probably need to customize this some more but hopefully it gets you started.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data temp;
set xyz;

month=month(date);
mon_name = put(date, monname3.);
year = year(date);

run;

proc sgplot data=temp;

where year in (1960, 1970, 1980, 1990);

series  x= month y=abc / group=year;

run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Thu, 14 Dec 2017 20:05:58 GMT</pubDate>
    <dc:creator>Reeza</dc:creator>
    <dc:date>2017-12-14T20:05:58Z</dc:date>
    <item>
      <title>SGPLOT - Series grouped by year</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/SGPLOT-Series-grouped-by-year/m-p/421327#M14494</link>
      <description>&lt;P&gt;Hi&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have a monthly time series from January 1960 to December 2017.&lt;/P&gt;
&lt;P&gt;I know to plot the whole series with SGPLOT.&lt;/P&gt;
&lt;P&gt;PROC SGPLOT DATA=XYZ;&lt;/P&gt;
&lt;P&gt;series x=date&amp;nbsp; y=ABC;&lt;/P&gt;
&lt;P&gt;xaxis values=('1jan60'd to '1dec17'd BY month);&lt;/P&gt;
&lt;P&gt;RUN;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;However, i would like to plot 4 sub-series on the same plot:&lt;/P&gt;
&lt;P&gt;series1 only year 1960&lt;/P&gt;
&lt;P&gt;series2 only year 1970&lt;/P&gt;
&lt;P&gt;series3 only year 1980&lt;/P&gt;
&lt;P&gt;series4 only year 1990&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 14 Dec 2017 20:01:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/SGPLOT-Series-grouped-by-year/m-p/421327#M14494</guid>
      <dc:creator>Phamhhm</dc:creator>
      <dc:date>2017-12-14T20:01:28Z</dc:date>
    </item>
    <item>
      <title>Re: SGPLOT - Series grouped by year</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/SGPLOT-Series-grouped-by-year/m-p/421329#M14495</link>
      <description>&lt;P&gt;Welcome to the SAS forums. Note that I've moved your post to the graphics board as it's more related.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Regarding your question, I would suggest the following approach:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;1. Use a WHERE clause to filter the data.&lt;/P&gt;
&lt;P&gt;2. Create new variables month &amp;amp; year that will reflect the month and year&lt;/P&gt;
&lt;P&gt;3. Same code with the WHERE filter and then use GROUP=YEAR and month as date instead.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You'll probably need to customize this some more but hopefully it gets you started.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data temp;
set xyz;

month=month(date);
mon_name = put(date, monname3.);
year = year(date);

run;

proc sgplot data=temp;

where year in (1960, 1970, 1980, 1990);

series  x= month y=abc / group=year;

run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 14 Dec 2017 20:05:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/SGPLOT-Series-grouped-by-year/m-p/421329#M14495</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-12-14T20:05:58Z</dc:date>
    </item>
    <item>
      <title>Re: SGPLOT - Series grouped by year</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/SGPLOT-Series-grouped-by-year/m-p/421330#M14496</link>
      <description>&lt;P&gt;Grouped by year or grouped by decade?&amp;nbsp; Either way, you need a grouping variable, which you can derive from DATE in a DATA step.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If grouping by year, you can simply "clone" DATE and apply a YEAR. format.&amp;nbsp; But if it's by decade, you'll need to do a little calculation to create a value for each decade and store that in a new variable.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Then you can use the GROUP= option on your SERIES statement.&lt;/P&gt;</description>
      <pubDate>Thu, 14 Dec 2017 20:06:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/SGPLOT-Series-grouped-by-year/m-p/421330#M14496</guid>
      <dc:creator>ChrisHemedinger</dc:creator>
      <dc:date>2017-12-14T20:06:05Z</dc:date>
    </item>
    <item>
      <title>Re: SGPLOT - Series grouped by year</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/SGPLOT-Series-grouped-by-year/m-p/421335#M14497</link>
      <description>&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;Nice solution and very fast answer.&lt;/P&gt;&lt;P&gt;I&amp;nbsp;just add two options: markers and xaxis values.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;DATA&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; temp;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;SET&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; OUT;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;month=month(date);&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;mon_name = put(date,&lt;/FONT&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;monname3.&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;);&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;year = year(date);&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;RUN&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;PROC&lt;/STRONG&gt;&lt;/FONT&gt; &lt;STRONG&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;SGPLOT&lt;/FONT&gt;&lt;/STRONG&gt; &lt;FONT color="#0000ff" face="Courier New" size="3"&gt;DATA&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;=temp;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;WHERE&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; year in (&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;1960&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;, &lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;1970&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;, &lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;1980&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;, &lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;1990&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;);&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;series&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Courier New" size="3"&gt;x&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;=month &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;y&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;=unemployment_A1 / &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;markers&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Courier New" size="3"&gt;group&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;=year;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;xaxis&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Courier New" size="3"&gt;values&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;=(&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;1&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt; TO &lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;12&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;);&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;RUN&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 14 Dec 2017 20:18:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/SGPLOT-Series-grouped-by-year/m-p/421335#M14497</guid>
      <dc:creator>Phamhhm</dc:creator>
      <dc:date>2017-12-14T20:18:14Z</dc:date>
    </item>
    <item>
      <title>Re: SGPLOT - Series grouped by year</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/SGPLOT-Series-grouped-by-year/m-p/421422#M14499</link>
      <description>Thanks for your answer and advice.&lt;BR /&gt;&lt;BR /&gt;Mr. Pham</description>
      <pubDate>Fri, 15 Dec 2017 01:26:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/SGPLOT-Series-grouped-by-year/m-p/421422#M14499</guid>
      <dc:creator>Phamhhm</dc:creator>
      <dc:date>2017-12-15T01:26:08Z</dc:date>
    </item>
  </channel>
</rss>

