<?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: Using sysdate to capture previous quarters/years in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Using-sysdate-to-capture-previous-quarters-years/m-p/412407#M100871</link>
    <description>&lt;P&gt;Use INTNX to increment the data the interval desired. It's not clear from your question exactly how you want that to work, so if you could post a more detailed example that would be helpful.&lt;/P&gt;</description>
    <pubDate>Fri, 10 Nov 2017 16:10:26 GMT</pubDate>
    <dc:creator>Reeza</dc:creator>
    <dc:date>2017-11-10T16:10:26Z</dc:date>
    <item>
      <title>Using sysdate to capture previous quarters/years</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Using-sysdate-to-capture-previous-quarters-years/m-p/412401#M100869</link>
      <description>&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 color="#0000ff" face="Courier New" size="3"&gt;_NULL_&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;month = month(input(&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;"&amp;amp;sysdate9"&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;,&lt;/FONT&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;date9.&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;));&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;year = year(input(&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;"&amp;amp;sysdate9"&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;,&lt;/FONT&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;date9.&lt;/FONT&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;call&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; symput(&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;'month'&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;,compress(put(month,&lt;/FONT&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;best.&lt;/FONT&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;call&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; symput(&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;'year'&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;,compress(put(year,&lt;/FONT&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;best.&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;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 face="Courier New" size="3"&gt;Output is &lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;44 %put &amp;amp;year;&lt;/P&gt;
&lt;P&gt;SYMBOLGEN: Macro variable YEAR resolves to 2017&lt;/P&gt;
&lt;P&gt;2017&lt;/P&gt;
&lt;P&gt;45 %put &amp;amp;month;&lt;/P&gt;
&lt;P&gt;SYMBOLGEN: Macro variable MONTH resolves to 11&lt;/P&gt;
&lt;P&gt;&lt;LI-WRAPPER&gt;&lt;/LI-WRAPPER&gt;&lt;/P&gt;
&lt;P&gt;Based on this month of November and this year.&lt;/P&gt;
&lt;P&gt;I have a report that will require me to go back several quarters and years.&amp;nbsp; I have a start up program that will give me the desired time period so lets say I need to not only pull November 2017 but I need to pull another date, say June 30, 2017?&amp;nbsp; How can I put in code like above to get me the desired date.&amp;nbsp; Quarterly would be even better (ie jan-mar=qtr1,&amp;nbsp; apr-jun=qtr2 etx&lt;/P&gt;</description>
      <pubDate>Fri, 10 Nov 2017 16:01:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Using-sysdate-to-capture-previous-quarters-years/m-p/412401#M100869</guid>
      <dc:creator>Q1983</dc:creator>
      <dc:date>2017-11-10T16:01:20Z</dc:date>
    </item>
    <item>
      <title>Re: Using sysdate to capture previous quarters/years</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Using-sysdate-to-capture-previous-quarters-years/m-p/412407#M100871</link>
      <description>&lt;P&gt;Use INTNX to increment the data the interval desired. It's not clear from your question exactly how you want that to work, so if you could post a more detailed example that would be helpful.&lt;/P&gt;</description>
      <pubDate>Fri, 10 Nov 2017 16:10:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Using-sysdate-to-capture-previous-quarters-years/m-p/412407#M100871</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-11-10T16:10:26Z</dc:date>
    </item>
    <item>
      <title>Re: Using sysdate to capture previous quarters/years</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Using-sysdate-to-capture-previous-quarters-years/m-p/412419#M100872</link>
      <description>&lt;P&gt;One approach would be to remove &amp;amp;SYSDATE from the DATA step:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%let refdate = &amp;amp;sysdate9;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3" color="#000080"&gt;&lt;STRONG&gt;data&lt;/STRONG&gt;&lt;/FONT&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;FONT face="Courier New" size="3" color="#0000ff"&gt;_NULL_&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;month = month(input(&lt;/FONT&gt;&lt;FONT face="Courier New" size="3" color="#800080"&gt;"&amp;amp;refdate"&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;,&lt;/FONT&gt;&lt;FONT face="Courier New" size="3" color="#008080"&gt;date9.&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;));&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;year = year(input(&lt;/FONT&gt;&lt;FONT face="Courier New" size="3" color="#800080"&gt;"&amp;amp;refdate"&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;,&lt;/FONT&gt;&lt;FONT face="Courier New" size="3" color="#008080"&gt;date9.&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;));&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3" color="#0000ff"&gt;call&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;symput(&lt;/FONT&gt;&lt;FONT face="Courier New" size="3" color="#800080"&gt;'month'&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;,compress(put(month,&lt;/FONT&gt;&lt;FONT face="Courier New" size="3" color="#008080"&gt;best.&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;)));&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3" color="#0000ff"&gt;call&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;symput(&lt;/FONT&gt;&lt;FONT face="Courier New" size="3" color="#800080"&gt;'year'&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;,compress(put(year,&lt;/FONT&gt;&lt;FONT face="Courier New" size="3" color="#008080"&gt;best.&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;)));&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3" color="#000080"&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 face="Courier New" size="3"&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="arial,helvetica,sans-serif" size="3"&gt;&lt;SPAN&gt;Now if you want a different date, just change the first line, such as:&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="arial,helvetica,sans-serif" size="3"&gt;&lt;SPAN&gt;%let refdate = 30JUN2017;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="arial,helvetica,sans-serif" size="3"&gt;&lt;SPAN&gt;Or, you might have automated logic that comes up with a way to replace REFDATE at the beginning of the program.&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 10 Nov 2017 16:39:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Using-sysdate-to-capture-previous-quarters-years/m-p/412419#M100872</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2017-11-10T16:39:54Z</dc:date>
    </item>
    <item>
      <title>Re: Using sysdate to capture previous quarters/years</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Using-sysdate-to-capture-previous-quarters-years/m-p/412428#M100874</link>
      <description>&lt;P&gt;I guess my point is if I have a proc sql statement like this&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;month = month(input(&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;"&amp;amp;sysdate9"&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;,&lt;/FONT&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;date9.&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;));&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;year = year(input(&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;"&amp;amp;sysdate9"&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;,&lt;/FONT&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;date9.&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;)); &lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;call symput('month',compress(put(month,best.)));&lt;/P&gt;
&lt;P&gt;call symput('year',compress(put(year,best.)));&lt;/P&gt;
&lt;P&gt;&lt;LI-WRAPPER&gt;&lt;/LI-WRAPPER&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc sql;&lt;/P&gt;
&lt;P&gt;create table test as&lt;/P&gt;
&lt;P&gt;select id,&lt;/P&gt;
&lt;P&gt;data_date&lt;/P&gt;
&lt;P&gt;from test1&lt;/P&gt;
&lt;P&gt;where year(data_date ) = 09 hard coded&lt;/P&gt;
&lt;P&gt;and month(data_date) = 2017 hard coded&lt;/P&gt;
&lt;P&gt;;quit;&lt;/P&gt;
&lt;P&gt;sample output&lt;BR /&gt;id&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; data_date&lt;BR /&gt;01&amp;nbsp;&amp;nbsp;&amp;nbsp; 30sep2017&lt;BR /&gt;02&amp;nbsp;&amp;nbsp;&amp;nbsp; 30sep2017&lt;/P&gt;
&lt;P&gt;The data_date field is a date9 field.&amp;nbsp; I want to dynamically(no hard code) to include previous quarters and dynamically list month, day or year.&amp;nbsp; For example I may have other data sets that must capture year = 2016 and month = 06&lt;/P&gt;
&lt;P&gt;Is there a way to take the sysdate and have it show a different date that the current date???&amp;nbsp; I will resubmit this in another forum also&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 10 Nov 2017 16:56:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Using-sysdate-to-capture-previous-quarters-years/m-p/412428#M100874</guid>
      <dc:creator>Q1983</dc:creator>
      <dc:date>2017-11-10T16:56:26Z</dc:date>
    </item>
    <item>
      <title>Sysdate to capture current and previous dates or quarters</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Using-sysdate-to-capture-previous-quarters-years/m-p/412430#M100876</link>
      <description>&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 color="#0000ff" face="Courier New" size="3"&gt;_NULL_&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;month = month(input(&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;"&amp;amp;sysdate9"&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;,&lt;/FONT&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;date9.&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;));&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;year = year(input(&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;"&amp;amp;sysdate9"&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;,&lt;/FONT&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;date9.&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;)); &lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;call symput('month',compress(put(month,best.)));&lt;/P&gt;
&lt;P&gt;call symput('year',compress(put(year,best.)));&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;LI-WRAPPER&gt;&lt;/LI-WRAPPER&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc sql;&lt;/P&gt;
&lt;P&gt;create table test as&lt;/P&gt;
&lt;P&gt;select id,&lt;/P&gt;
&lt;P&gt;data_date&lt;/P&gt;
&lt;P&gt;from test1&lt;/P&gt;
&lt;P&gt;where year(data_date ) = 09 hard coded&lt;/P&gt;
&lt;P&gt;and month(data_date) = 2017 hard coded&lt;/P&gt;
&lt;P&gt;;quit;&lt;/P&gt;
&lt;P&gt;sample output&lt;BR /&gt;id&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; data_date&lt;BR /&gt;01&amp;nbsp;&amp;nbsp;&amp;nbsp; 30sep2017&lt;BR /&gt;02&amp;nbsp;&amp;nbsp;&amp;nbsp; 30sep2017&lt;/P&gt;
&lt;P&gt;The data_date field is a date9 field.&amp;nbsp; I want to dynamically(no hard code) to include previous quarters and dynamically list month, day or year.&amp;nbsp; For example I may have other data sets that must capture year = 2016 and month = 06&lt;/P&gt;
&lt;P&gt;Is there a way to take the sysdate and have it show a different date that the current date???&amp;nbsp; I will resubmit this in another forum also&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 10 Nov 2017 16:58:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Using-sysdate-to-capture-previous-quarters-years/m-p/412430#M100876</guid>
      <dc:creator>Q1983</dc:creator>
      <dc:date>2017-11-10T16:58:09Z</dc:date>
    </item>
    <item>
      <title>Re: Using sysdate to capture previous quarters/years</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Using-sysdate-to-capture-previous-quarters-years/m-p/412431#M100877</link>
      <description>&lt;P&gt;Please do not post multiple versions of the same question.&lt;/P&gt;</description>
      <pubDate>Fri, 10 Nov 2017 17:02:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Using-sysdate-to-capture-previous-quarters-years/m-p/412431#M100877</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-11-10T17:02:26Z</dc:date>
    </item>
  </channel>
</rss>

