<?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: SAS date issue in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/SAS-date-issue/m-p/459811#M116826</link>
    <description>&lt;P&gt;SAS dates need to be specified as date literals to be automatically recognized as dates.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;How is the compiler supposed to know if you want 2017-01-12 = 2017-1-12 = 2017-13=2004&lt;/P&gt;
&lt;P&gt;or that it's a date?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The way to do that is specify dates in a date literal format:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let date = '12Jan2017'd;
%let et=%sysfunc(intnx(month,&amp;amp;date.,1),yymmdd10.);
%put &amp;amp;et.;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;This works. If you want to specify the date in a different format, then YOU need to handle the conversion, which is demonstrated in&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/138205"&gt;@novinosrin&lt;/a&gt;&amp;nbsp;code using the INPUTN()&amp;nbsp; function. (INPUT() does not work with %SYSFUNC, but INPUTN() does)&lt;/P&gt;</description>
    <pubDate>Thu, 03 May 2018 19:21:52 GMT</pubDate>
    <dc:creator>Reeza</dc:creator>
    <dc:date>2018-05-03T19:21:52Z</dc:date>
    <item>
      <title>SAS date issue</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-date-issue/m-p/459794#M116822</link>
      <description>&lt;P&gt;Iam trying to get the next month of a date.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let date =2017-01-12;
%let et=%sysfunc(intnx(month,&amp;amp;date.,1),yymmdd10.);
%put &amp;amp;et.;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But result is different. What went wrong&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;1          OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
 61         
 62         %put &amp;amp;et.;
 1965-07-01
 63         
 64         OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
 77         &lt;BR /&gt;&lt;BR /&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 03 May 2018 18:30:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-date-issue/m-p/459794#M116822</guid>
      <dc:creator>suresh123</dc:creator>
      <dc:date>2018-05-03T18:30:15Z</dc:date>
    </item>
    <item>
      <title>Re: SAS date issue</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-date-issue/m-p/459797#M116823</link>
      <description>&lt;P&gt;Try this&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let date =2017-01-12;
%let et=%sysfunc(intnx(month,%sysfunc(inputn(&amp;amp;date.,yymmdd10.)),1),yymmdd10.);
%put &amp;amp;et.;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 03 May 2018 18:34:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-date-issue/m-p/459797#M116823</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2018-05-03T18:34:12Z</dc:date>
    </item>
    <item>
      <title>Re: SAS date issue</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-date-issue/m-p/459799#M116824</link>
      <description>&lt;P&gt;For same dates instead of 1st of month--&amp;gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let date =2017-01-12;
%let et=%sysfunc(intnx(month,%sysfunc(inputn(&amp;amp;date.,yymmdd10.)),1,s),yymmdd10.);
%put &amp;amp;et.;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 03 May 2018 18:36:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-date-issue/m-p/459799#M116824</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2018-05-03T18:36:15Z</dc:date>
    </item>
    <item>
      <title>Re: SAS date issue</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-date-issue/m-p/459811#M116826</link>
      <description>&lt;P&gt;SAS dates need to be specified as date literals to be automatically recognized as dates.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;How is the compiler supposed to know if you want 2017-01-12 = 2017-1-12 = 2017-13=2004&lt;/P&gt;
&lt;P&gt;or that it's a date?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The way to do that is specify dates in a date literal format:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let date = '12Jan2017'd;
%let et=%sysfunc(intnx(month,&amp;amp;date.,1),yymmdd10.);
%put &amp;amp;et.;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;This works. If you want to specify the date in a different format, then YOU need to handle the conversion, which is demonstrated in&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/138205"&gt;@novinosrin&lt;/a&gt;&amp;nbsp;code using the INPUTN()&amp;nbsp; function. (INPUT() does not work with %SYSFUNC, but INPUTN() does)&lt;/P&gt;</description>
      <pubDate>Thu, 03 May 2018 19:21:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-date-issue/m-p/459811#M116826</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-05-03T19:21:52Z</dc:date>
    </item>
    <item>
      <title>Re: SAS date issue</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-date-issue/m-p/459813#M116827</link>
      <description>&lt;P&gt;2017-01-12 used as a date parameter will be evaluated as 2004 (2017 minus 1 minus 12), which means 2004 days after 01jan1960.&lt;/P&gt;
&lt;P&gt;Use a proper informat as &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/138205"&gt;@novinosrin&lt;/a&gt;&amp;nbsp;suggests.&lt;/P&gt;
&lt;P&gt;Hint: macro variables to be used as dates should contain raw date values (5-digit numbers as of now); human-readable form is not needed. Makes everything easier.&lt;/P&gt;</description>
      <pubDate>Thu, 03 May 2018 19:28:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-date-issue/m-p/459813#M116827</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2018-05-03T19:28:26Z</dc:date>
    </item>
  </channel>
</rss>

