<?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 Add refline for each year (date sequence) on sgplot in Graphics Programming</title>
    <link>https://communities.sas.com/t5/Graphics-Programming/Add-refline-for-each-year-date-sequence-on-sgplot/m-p/257492#M9329</link>
    <description>&lt;P&gt;Hi - I am trying to add a refline at&amp;nbsp;each year between a minimum and maximum date, with no success. &amp;nbsp;Code to date is as follows:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%LET date1 = '01Jan2015';  
%LET date2 = '01Jan2018'; 

data test;
	date= &amp;amp;date1.d;
	do while(date &amp;lt;= &amp;amp;date2.d);
		y = rand('NORMAL', 0, 1);
		output;
		date=intnx('month', date, 1, 's');
	end;
	format date yymmdd10.;
  run;

proc print data=test(obs=5);
run;

proc sgplot data=test;
   series x=date y=y /markers;
   refline &amp;amp;date1.d / axis=x lineattrs=(color=red);
   *refline (&amp;amp;date1.d to &amp;amp;date2.d by month) / axis=x lineattrs=(color=red);
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Any help would be greatly appreciated.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks.&lt;/P&gt;</description>
    <pubDate>Fri, 18 Mar 2016 02:06:45 GMT</pubDate>
    <dc:creator>mduarte</dc:creator>
    <dc:date>2016-03-18T02:06:45Z</dc:date>
    <item>
      <title>Add refline for each year (date sequence) on sgplot</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/Add-refline-for-each-year-date-sequence-on-sgplot/m-p/257492#M9329</link>
      <description>&lt;P&gt;Hi - I am trying to add a refline at&amp;nbsp;each year between a minimum and maximum date, with no success. &amp;nbsp;Code to date is as follows:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%LET date1 = '01Jan2015';  
%LET date2 = '01Jan2018'; 

data test;
	date= &amp;amp;date1.d;
	do while(date &amp;lt;= &amp;amp;date2.d);
		y = rand('NORMAL', 0, 1);
		output;
		date=intnx('month', date, 1, 's');
	end;
	format date yymmdd10.;
  run;

proc print data=test(obs=5);
run;

proc sgplot data=test;
   series x=date y=y /markers;
   refline &amp;amp;date1.d / axis=x lineattrs=(color=red);
   *refline (&amp;amp;date1.d to &amp;amp;date2.d by month) / axis=x lineattrs=(color=red);
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Any help would be greatly appreciated.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks.&lt;/P&gt;</description>
      <pubDate>Fri, 18 Mar 2016 02:06:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/Add-refline-for-each-year-date-sequence-on-sgplot/m-p/257492#M9329</guid>
      <dc:creator>mduarte</dc:creator>
      <dc:date>2016-03-18T02:06:45Z</dc:date>
    </item>
    <item>
      <title>Re: Add refline for each year (date sequence) on sgplot</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/Add-refline-for-each-year-date-sequence-on-sgplot/m-p/257496#M9330</link>
      <description>&lt;P&gt;You need to use a data set variable for the REFLINE statement. &amp;nbsp;In the program below,&amp;nbsp;I have computed a new one called Date2 in the data step to demonstrate the usage.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;proc sgplot data=test;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; series x=date y=y /markers;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; refline &lt;STRONG&gt;date2&lt;/STRONG&gt;/ axis=x lineattrs=(color=red);&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;run;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;IMG src="https://communities.sas.com/t5/image/serverpage/image-id/2355iD51A8430C93B4EE9/image-size/medium?v=mpbl-1&amp;amp;px=-1" border="0" alt="Dateref.png" title="Dateref.png" /&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%LET date1 = '01Jan2015'; &lt;BR /&gt;%LET date2 = '01Jan2018';&lt;/P&gt;
&lt;P&gt;data test;&lt;BR /&gt; date= &amp;amp;date1.d;&lt;BR /&gt; do while(date &amp;lt;= &amp;amp;date2.d);&lt;BR /&gt; date2=.;&lt;BR /&gt; y = rand('NORMAL', 0, 1);&lt;BR /&gt; if date &amp;gt;= '01jan2016'd and date &amp;lt;= '01Jan2017'd then date2=date;&lt;BR /&gt; output;&lt;BR /&gt; date=intnx('month', date, 1, 's');&lt;BR /&gt; end;&lt;BR /&gt; format date date2 yymmdd10.;&lt;BR /&gt; run;&lt;/P&gt;
&lt;P&gt;proc print data=test;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;proc sgplot data=test;&lt;BR /&gt; series x=date y=y /markers;&lt;BR /&gt; refline date2/ axis=x lineattrs=(color=red);&lt;BR /&gt; *refline (&amp;amp;date1.d to &amp;amp;date2.d by month) / axis=x lineattrs=(color=red);&lt;BR /&gt;run;&lt;/P&gt;</description>
      <pubDate>Fri, 18 Mar 2016 02:43:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/Add-refline-for-each-year-date-sequence-on-sgplot/m-p/257496#M9330</guid>
      <dc:creator>Jay54</dc:creator>
      <dc:date>2016-03-18T02:43:54Z</dc:date>
    </item>
    <item>
      <title>Re: Add refline for each year (date sequence) on sgplot</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/Add-refline-for-each-year-date-sequence-on-sgplot/m-p/257879#M9332</link>
      <description>&lt;P&gt;Hi &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13856"&gt;@Jay54﻿&lt;/a&gt;. &amp;nbsp;Thanks for the suggestion&amp;nbsp;although&amp;nbsp;I am not sure it will work in this case. &amp;nbsp;Firstly, my data already exists (the data I created in the post was just to make the example reproducible) and it is not certain that a data point will exist on each year.&lt;/P&gt;</description>
      <pubDate>Sun, 20 Mar 2016 21:47:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/Add-refline-for-each-year-date-sequence-on-sgplot/m-p/257879#M9332</guid>
      <dc:creator>mduarte</dc:creator>
      <dc:date>2016-03-20T21:47:29Z</dc:date>
    </item>
  </channel>
</rss>

