<?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: DATE calculation in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/DATE-calculation/m-p/607852#M176782</link>
    <description>&lt;P&gt;Now I'm trying to merge two files by "date", but I can not, it seem the same problem, the format of "date" is not recognized.&lt;/P&gt;&lt;P&gt;Here is the log information:&lt;/P&gt;&lt;P&gt;NOTE: Table has been opened in browse mode.&lt;BR /&gt;ERROR: There was a problem with the format so BEST. was used.&lt;BR /&gt;ERROR: There was a problem with the format so BEST. was used.&lt;/P&gt;&lt;P&gt;the code I used is&amp;nbsp;&lt;/P&gt;&lt;P&gt;DATA master;&lt;BR /&gt;MERGE T2 (in=a)&lt;BR /&gt;sp2 (in=b);&lt;BR /&gt;by date;&lt;BR /&gt;if A;&lt;BR /&gt;run;&lt;/P&gt;</description>
    <pubDate>Wed, 27 Nov 2019 20:37:59 GMT</pubDate>
    <dc:creator>Xinhui</dc:creator>
    <dc:date>2019-11-27T20:37:59Z</dc:date>
    <item>
      <title>DATE calculation</title>
      <link>https://communities.sas.com/t5/SAS-Programming/DATE-calculation/m-p/605979#M175904</link>
      <description>&lt;P&gt;Hi there&amp;nbsp;&lt;/P&gt;&lt;P&gt;Plase see the attached data file, I'm attempt to calculate the days between varible 'date' and 'edate',&amp;nbsp; I used following codes:&amp;nbsp;&lt;/P&gt;&lt;P&gt;data final3;&lt;BR /&gt;set final2;&lt;BR /&gt;FORMAT DATE MMDDYY10.;&lt;BR /&gt;FORMAT EDATE MMDDYY10.;&lt;BR /&gt;DD=DATE- EDATE;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;However, all of the DD is missing in the file, it seems it not calculate correctly.&amp;nbsp;&lt;/P&gt;&lt;P&gt;the code works in other project.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I don't know why it not work in this case.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I suspect that maybe the format of the "date" and "edate" has some problem.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks in advance.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 21 Nov 2019 01:00:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/DATE-calculation/m-p/605979#M175904</guid>
      <dc:creator>Xinhui</dc:creator>
      <dc:date>2019-11-21T01:00:38Z</dc:date>
    </item>
    <item>
      <title>Re: DATE calculation</title>
      <link>https://communities.sas.com/t5/SAS-Programming/DATE-calculation/m-p/605983#M175906</link>
      <description>&lt;P&gt;&lt;EM&gt;&amp;gt; I suspect that maybe the format of the "date" and "edate" has some problem.&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;No. Formats do not affect such calculations.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Show us the log, and a proc contents of table FINAL2.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 21 Nov 2019 01:50:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/DATE-calculation/m-p/605983#M175906</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2019-11-21T01:50:28Z</dc:date>
    </item>
    <item>
      <title>Re: DATE calculation</title>
      <link>https://communities.sas.com/t5/SAS-Programming/DATE-calculation/m-p/606005#M175917</link>
      <description>&lt;P&gt;I suspect your dates are strings (and this should generate messages in the log when you run the code). Anyway,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/* Try replacing */

FORMAT DATE MMDDYY10.;
FORMAT EDATE MMDDYY10.;
DD=DATE- EDATE;

/* With */

dt = input(date, mmddyy10.);
edt = input(edate, mmddyy10.);
dd = dt - edt;

/* Or */

dt = input(date, yymmdd10.);
edt = input(edate, yymmdd10.);
dd = dt - edt;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 21 Nov 2019 04:23:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/DATE-calculation/m-p/606005#M175917</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2019-11-21T04:23:23Z</dc:date>
    </item>
    <item>
      <title>Re: DATE calculation</title>
      <link>https://communities.sas.com/t5/SAS-Programming/DATE-calculation/m-p/606008#M175919</link>
      <description>&lt;P&gt;Thanks for your reply. it still not work.&lt;/P&gt;&lt;P&gt;log information shows "ERROR: There was a problem with the format so BEST was used"&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 21 Nov 2019 04:45:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/DATE-calculation/m-p/606008#M175919</guid>
      <dc:creator>Xinhui</dc:creator>
      <dc:date>2019-11-21T04:45:52Z</dc:date>
    </item>
    <item>
      <title>Re: DATE calculation</title>
      <link>https://communities.sas.com/t5/SAS-Programming/DATE-calculation/m-p/606010#M175920</link>
      <description>&lt;P&gt;the sencond one works!!!! Thank you so much!!!&lt;/P&gt;</description>
      <pubDate>Thu, 21 Nov 2019 04:58:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/DATE-calculation/m-p/606010#M175920</guid>
      <dc:creator>Xinhui</dc:creator>
      <dc:date>2019-11-21T04:58:31Z</dc:date>
    </item>
    <item>
      <title>Re: DATE calculation</title>
      <link>https://communities.sas.com/t5/SAS-Programming/DATE-calculation/m-p/607814#M176761</link>
      <description>&lt;P&gt;Sorry it was worked, but I rerun the code, it failed again, why this happened?&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 27 Nov 2019 19:13:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/DATE-calculation/m-p/607814#M176761</guid>
      <dc:creator>Xinhui</dc:creator>
      <dc:date>2019-11-27T19:13:01Z</dc:date>
    </item>
    <item>
      <title>Re: DATE calculation</title>
      <link>https://communities.sas.com/t5/SAS-Programming/DATE-calculation/m-p/607823#M176767</link>
      <description>&lt;P&gt;We can't tell unless you post the SAS log showing the problem. If you get different results (errors) with the same code, then the change must be in the data.&lt;/P&gt;</description>
      <pubDate>Wed, 27 Nov 2019 19:43:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/DATE-calculation/m-p/607823#M176767</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2019-11-27T19:43:46Z</dc:date>
    </item>
    <item>
      <title>Re: DATE calculation</title>
      <link>https://communities.sas.com/t5/SAS-Programming/DATE-calculation/m-p/607826#M176769</link>
      <description>&lt;P&gt;NOTE: Numeric values have been converted to character values at the places given by: (Line):(Column).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 622:12&amp;nbsp;&amp;nbsp; 623:13&lt;/P&gt;&lt;P&gt;NOTE: Invalid argument to function INPUT at line 623 column 7.&lt;/P&gt;&lt;P&gt;Company_Name=ARCHER-DANIELS-MIDLAND CO TICKER=ADM EDATE=20140204 Date=20100107 Price=31.23 dt=22189 edt=. dd=.&lt;/P&gt;&lt;P&gt;_ERROR_=1 _N_=4&lt;/P&gt;&lt;P&gt;NOTE: Invalid argument to function INPUT at line 623 column 7.&lt;/P&gt;&lt;P&gt;Company_Name=ARCHER-DANIELS-MIDLAND CO TICKER=ADM EDATE=20150203 Date=20100108 Price=30.84 dt=22189 edt=. dd=.&lt;/P&gt;&lt;P&gt;_ERROR_=1 _N_=5&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;this is the log information&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 27 Nov 2019 19:44:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/DATE-calculation/m-p/607826#M176769</guid>
      <dc:creator>Xinhui</dc:creator>
      <dc:date>2019-11-27T19:44:55Z</dc:date>
    </item>
    <item>
      <title>Re: DATE calculation</title>
      <link>https://communities.sas.com/t5/SAS-Programming/DATE-calculation/m-p/607830#M176773</link>
      <description>&lt;P&gt;Looks like DATE and EDATE are not character strings anymore, but numbers.. You could do:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE class=" language-sas"&gt;&lt;CODE class="  language-sas"&gt;dt &lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt; &lt;SPAN class="token keyword"&gt;input&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;(put(&lt;/SPAN&gt;&lt;SPAN class="token function"&gt;date,best8.)&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;,&lt;/SPAN&gt; yymmdd10&lt;SPAN class="token punctuation"&gt;.&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;
edt &lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt; &lt;SPAN class="token keyword"&gt;input&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;(put(&lt;/SPAN&gt;edate, best8.)&lt;SPAN class="token punctuation"&gt;,&lt;/SPAN&gt; yymmdd10&lt;SPAN class="token punctuation"&gt;.&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 27 Nov 2019 19:54:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/DATE-calculation/m-p/607830#M176773</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2019-11-27T19:54:19Z</dc:date>
    </item>
    <item>
      <title>Re: DATE calculation</title>
      <link>https://communities.sas.com/t5/SAS-Programming/DATE-calculation/m-p/607835#M176777</link>
      <description>&lt;P&gt;works now. Thank you so much!!!!!!!&lt;/P&gt;&lt;P&gt;But do you know why this happened? I use the same file, why old code not work?&lt;/P&gt;</description>
      <pubDate>Wed, 27 Nov 2019 20:01:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/DATE-calculation/m-p/607835#M176777</guid>
      <dc:creator>Xinhui</dc:creator>
      <dc:date>2019-11-27T20:01:35Z</dc:date>
    </item>
    <item>
      <title>Re: DATE calculation</title>
      <link>https://communities.sas.com/t5/SAS-Programming/DATE-calculation/m-p/607836#M176778</link>
      <description>&lt;P&gt;With SAS, the same code normally yields the same result. But if your data resides in Excel... anything can happen.&lt;/P&gt;</description>
      <pubDate>Wed, 27 Nov 2019 20:03:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/DATE-calculation/m-p/607836#M176778</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2019-11-27T20:03:47Z</dc:date>
    </item>
    <item>
      <title>Re: DATE calculation</title>
      <link>https://communities.sas.com/t5/SAS-Programming/DATE-calculation/m-p/607852#M176782</link>
      <description>&lt;P&gt;Now I'm trying to merge two files by "date", but I can not, it seem the same problem, the format of "date" is not recognized.&lt;/P&gt;&lt;P&gt;Here is the log information:&lt;/P&gt;&lt;P&gt;NOTE: Table has been opened in browse mode.&lt;BR /&gt;ERROR: There was a problem with the format so BEST. was used.&lt;BR /&gt;ERROR: There was a problem with the format so BEST. was used.&lt;/P&gt;&lt;P&gt;the code I used is&amp;nbsp;&lt;/P&gt;&lt;P&gt;DATA master;&lt;BR /&gt;MERGE T2 (in=a)&lt;BR /&gt;sp2 (in=b);&lt;BR /&gt;by date;&lt;BR /&gt;if A;&lt;BR /&gt;run;&lt;/P&gt;</description>
      <pubDate>Wed, 27 Nov 2019 20:37:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/DATE-calculation/m-p/607852#M176782</guid>
      <dc:creator>Xinhui</dc:creator>
      <dc:date>2019-11-27T20:37:59Z</dc:date>
    </item>
    <item>
      <title>Re: DATE calculation</title>
      <link>https://communities.sas.com/t5/SAS-Programming/DATE-calculation/m-p/607857#M176786</link>
      <description>&lt;P&gt;the format of "date" in file T2 is&amp;nbsp;BEST12.&lt;/P&gt;&lt;P&gt;the format of "date" in file SP2 is&amp;nbsp;YYMMDDN8.&lt;/P&gt;</description>
      <pubDate>Wed, 27 Nov 2019 20:55:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/DATE-calculation/m-p/607857#M176786</guid>
      <dc:creator>Xinhui</dc:creator>
      <dc:date>2019-11-27T20:55:44Z</dc:date>
    </item>
    <item>
      <title>Re: DATE calculation</title>
      <link>https://communities.sas.com/t5/SAS-Programming/DATE-calculation/m-p/607863#M176788</link>
      <description>&lt;P&gt;These error messages are not related to the merge operation. They likely occur when you try to display the dataset with the SAS dataset viewer (a very poor component of the SAS environment). Try displaying your data with proc print&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc print data=myData(obs=30); run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;.&lt;/P&gt;</description>
      <pubDate>Wed, 27 Nov 2019 21:07:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/DATE-calculation/m-p/607863#M176788</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2019-11-27T21:07:14Z</dc:date>
    </item>
    <item>
      <title>Re: DATE calculation</title>
      <link>https://communities.sas.com/t5/SAS-Programming/DATE-calculation/m-p/607876#M176793</link>
      <description>&lt;P&gt;in the print table the ‘date' showed as *******&lt;/P&gt;</description>
      <pubDate>Wed, 27 Nov 2019 21:49:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/DATE-calculation/m-p/607876#M176793</guid>
      <dc:creator>Xinhui</dc:creator>
      <dc:date>2019-11-27T21:49:11Z</dc:date>
    </item>
    <item>
      <title>Re: DATE calculation</title>
      <link>https://communities.sas.com/t5/SAS-Programming/DATE-calculation/m-p/607882#M176797</link>
      <description>&lt;P&gt;SAS will print **** when the value is too large/small for the format attached.&lt;/P&gt;
&lt;P&gt;If you attach a date format (like DATE, MMDDYY, DDMMYY, YYMMDD etc) to a variable that has values like 20,191,127 then you are asking it to display a date that is probably in the year 53,320.&amp;nbsp; But the DATE format can only display 4 digits for the year part of a date.&lt;/P&gt;
&lt;PRE&gt;1131  data _null_;
1132    date= 20191127 ;
1133    year_est = floor(date/365.25) - 1960;
1134    put date= comma20. year_est= comma10.;
1135  run;

date=20,191,127 year_est=53,320
&lt;/PRE&gt;</description>
      <pubDate>Wed, 27 Nov 2019 22:16:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/DATE-calculation/m-p/607882#M176797</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2019-11-27T22:16:18Z</dc:date>
    </item>
  </channel>
</rss>

