<?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: Add date to file - giving JAN1960 in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Add-date-to-file-giving-JAN1960/m-p/322919#M71511</link>
    <description>&lt;P&gt;The following should work:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;"&amp;amp;path\V_B_%sysfunc(intnx(month,%sysfunc(today()),-1,b),monyy7.).csv"&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;You get a date of 1960 because function &lt;EM&gt;month(-1)&lt;/EM&gt; doesn't work the way&amp;nbsp;you believe it does (look it up in the manual) and returns a value of 12 - which SAS interpretes as the 12th day when the count of days starts &amp;nbsp;- which is 1/1/1960.&lt;/P&gt;</description>
    <pubDate>Fri, 06 Jan 2017 09:10:42 GMT</pubDate>
    <dc:creator>Patrick</dc:creator>
    <dc:date>2017-01-06T09:10:42Z</dc:date>
    <item>
      <title>Add date to file - giving JAN1960</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Add-date-to-file-giving-JAN1960/m-p/322907#M71503</link>
      <description>&lt;P&gt;Good day,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I would like to add a date to a file, however, it should reflect the previous month. Reason is the files for December will be received and ran in January, however, the file name should then have DEC2016 in it.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My code works, however, it gives an output of JAN1960 (which is day 0).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I cannot seem to find what the issue is. My code below:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;PROC EXPORT 
DATA = V_B
OUTFILE = "&amp;amp;path\V_B_%sysfunc(putn(%eval(%sysfunc(month(-1))),monyy7)).csv"
dbms= csv replace;
RUN;&lt;/PRE&gt;&lt;P&gt;Thank you&lt;/P&gt;</description>
      <pubDate>Fri, 06 Jan 2017 08:23:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Add-date-to-file-giving-JAN1960/m-p/322907#M71503</guid>
      <dc:creator>c1991</dc:creator>
      <dc:date>2017-01-06T08:23:22Z</dc:date>
    </item>
    <item>
      <title>Re: Add date to file - giving JAN1960</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Add-date-to-file-giving-JAN1960/m-p/322914#M71506</link>
      <description>&lt;P&gt;Hi.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This will sort it for you I think.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt; * create macro var with desired date, migth be helpful ahead;&lt;BR /&gt; %let FDATE=%sysfunc(putn(%sysfunc(intnx(MONTH,%sysfunc(date()),-1)),monyy7.));&lt;BR /&gt;&lt;BR /&gt;PROC EXPORT 
     DATA = V_B&lt;BR /&gt;     OUTFILE = "&amp;amp;path\V_B_&amp;amp;FDATE..csv"
     dbms= csv replace;
RUN;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;You need do use the DATE function to retrieve the filesystems date and the INTNX function to subtract one month from it.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;More on DATE:&amp;nbsp;&lt;A href="http://support.sas.com/documentation/cdl/en/etsug/63939/HTML/default/viewer.htm#etsug_intervals_sect014.htm" target="_blank"&gt;http://support.sas.com/documentation/cdl/en/etsug/63939/HTML/default/viewer.htm#etsug_intervals_sect014.htm&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;More on INTNX:&amp;nbsp;&lt;A href="https://support.sas.com/documentation/cdl/en/lefunctionsref/63354/HTML/default/viewer.htm#p10v3sa3i4kfxfn1sovhi5xzxh8n.htm" target="_blank"&gt;https://support.sas.com/documentation/cdl/en/lefunctionsref/63354/HTML/default/viewer.htm#p10v3sa3i4kfxfn1sovhi5xzxh8n.htm&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hope it helps.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Daniel Santos&amp;nbsp;@ &lt;A href="http://www.cgd.pt" target="_blank"&gt;www.cgd.pt&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 06 Jan 2017 08:55:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Add-date-to-file-giving-JAN1960/m-p/322914#M71506</guid>
      <dc:creator>Daniel-Santos</dc:creator>
      <dc:date>2017-01-06T08:55:54Z</dc:date>
    </item>
    <item>
      <title>Re: Add date to file - giving JAN1960</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Add-date-to-file-giving-JAN1960/m-p/322919#M71511</link>
      <description>&lt;P&gt;The following should work:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;"&amp;amp;path\V_B_%sysfunc(intnx(month,%sysfunc(today()),-1,b),monyy7.).csv"&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;You get a date of 1960 because function &lt;EM&gt;month(-1)&lt;/EM&gt; doesn't work the way&amp;nbsp;you believe it does (look it up in the manual) and returns a value of 12 - which SAS interpretes as the 12th day when the count of days starts &amp;nbsp;- which is 1/1/1960.&lt;/P&gt;</description>
      <pubDate>Fri, 06 Jan 2017 09:10:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Add-date-to-file-giving-JAN1960/m-p/322919#M71511</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2017-01-06T09:10:42Z</dc:date>
    </item>
    <item>
      <title>Re: Add date to file - giving JAN1960</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Add-date-to-file-giving-JAN1960/m-p/322928#M71517</link>
      <description>&lt;P&gt;Thank you. Both solutions work.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm still fairly new at sas, so thank you for helping me &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 06 Jan 2017 10:27:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Add-date-to-file-giving-JAN1960/m-p/322928#M71517</guid>
      <dc:creator>c1991</dc:creator>
      <dc:date>2017-01-06T10:27:45Z</dc:date>
    </item>
  </channel>
</rss>

