<?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: Potential bug with assigning numeric date values to variables in SAS Software for Learning Community</title>
    <link>https://communities.sas.com/t5/SAS-Software-for-Learning/Potential-bug-with-assigning-numeric-date-values-to-variables/m-p/807826#M468</link>
    <description>&lt;P&gt;If Edate or Ddate are supposed to be date values then why would be adding another date to them???&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;What do you expect to get for 01Jan1960 + 07May2000? That is what this does when edate is 0&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=""&gt;edate + day0;&lt;BR /&gt;or&amp;nbsp;similar&amp;nbsp;for&amp;nbsp;intnx&lt;BR /&gt;('day',day0,edate)&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;A value of 0 when treated as a date is 01JAN1960 which is the base for SAS dates. So when you add anything to that it is like 0+ x, which yields x. So you get the date from X.&lt;/P&gt;
&lt;P&gt;You don't describe what you are actually trying to do so can't make suggestions.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Hint: ASSIGN date formats like DATE9. or YYMMDD10. to any variable that is supposed to be a date.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Read this:&lt;/P&gt;
&lt;P&gt;&lt;A href="https://communities.sas.com/t5/SAS-Communities-Library/Working-with-Dates-and-Times-in-SAS-Tutorial/ta-p/424354" target="_blank"&gt;https://communities.sas.com/t5/SAS-Communities-Library/Working-with-Dates-and-Times-in-SAS-Tutorial/ta-p/424354&lt;/A&gt; has a PDF with much information about dates.&lt;/P&gt;</description>
    <pubDate>Thu, 14 Apr 2022 14:25:16 GMT</pubDate>
    <dc:creator>ballardw</dc:creator>
    <dc:date>2022-04-14T14:25:16Z</dc:date>
    <item>
      <title>Potential bug with assigning numeric date values to variables</title>
      <link>https://communities.sas.com/t5/SAS-Software-for-Learning/Potential-bug-with-assigning-numeric-date-values-to-variables/m-p/807776#M465</link>
      <description>&lt;P&gt;&lt;SPAN&gt;Initially, I tried to run the code below, where &lt;EM&gt;edate&lt;/EM&gt; and d&lt;EM&gt;date&lt;/EM&gt; were originally non-negative integers (0, 1, 2, ...). However, when&amp;nbsp;&lt;EM&gt;edate&lt;/EM&gt;&amp;nbsp;or &lt;SPAN&gt;&lt;EM&gt;ddate&amp;nbsp;&lt;/EM&gt;&lt;/SPAN&gt;were originally 0, the new rewritten&amp;nbsp;&lt;EM&gt;edate &lt;/EM&gt;or&lt;EM&gt;&amp;nbsp;&lt;SPAN&gt;ddate&lt;/SPAN&gt;&lt;/EM&gt; became&amp;nbsp;14736, instead of the correct&amp;nbsp;&lt;SPAN&gt;14737 from&amp;nbsp;&lt;EM&gt;&lt;SPAN class=""&gt;day0 = mdy(05, 07, 00)&lt;/SPAN&gt;&lt;/EM&gt;&lt;EM&gt;.&amp;nbsp;&lt;/EM&gt;It was fine when&amp;nbsp;&lt;EM&gt;edate&lt;/EM&gt; or &lt;EM&gt;ddate&amp;nbsp;&lt;/EM&gt;were positive integers.&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;PRE&gt;data csp.task3;&lt;BR /&gt;&lt;CODE class=""&gt;	&lt;/CODE&gt;set csp.task2;&lt;BR /&gt;&lt;CODE class=""&gt;	&lt;/CODE&gt;day0 = mdy(05, 07, 00);&lt;BR /&gt;&lt;CODE class=""&gt;	&lt;/CODE&gt;edate = edate + day0;&lt;BR /&gt;&lt;CODE class=""&gt;	&lt;/CODE&gt;ddate = ddate0 + day0;&lt;BR /&gt;run;&lt;/PRE&gt;&lt;SPAN class=""&gt;&lt;SPAN&gt;Then, I tried to create placeholder variables to see if the problem can be avoided.&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV class=""&gt;&lt;PRE&gt;&lt;CODE class=""&gt;data csp.task3;
	set csp.task2;
	day0 = mdy(05, 07, 00);
	edate0 = edate + day0;
	ddate0 = ddate + day0;
	edate = edate0;
	ddate = ddate0;
	format edate ddate day0 date9.;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;SPAN class=""&gt;&lt;SPAN class=""&gt;&lt;SPAN&gt;And I also tried this:&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;PRE&gt;&lt;CODE class=""&gt;data csp.task3;
	set csp.task2;
	day0 = mdy(05, 07, 00);
	edate0 = intnx('day', day0, edate);
	ddate0 = intnx('day', day0, ddate);
	edate = edate0;
	ddate = ddate0;
	format edate ddate day0 date9.;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN class=""&gt;&lt;SPAN&gt;Well, the problem persists in an even more bizarre way:&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/DIV&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;STRONG&gt;edate&lt;/STRONG&gt;&lt;/TD&gt;&lt;TD&gt;&lt;STRONG&gt;ddate&lt;/STRONG&gt;&lt;/TD&gt;&lt;TD&gt;&lt;STRONG&gt;edate0&lt;/STRONG&gt;&lt;/TD&gt;&lt;TD&gt;&lt;STRONG&gt;ddate0&lt;/STRONG&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;P&gt;1&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;FONT color="#FF0000"&gt;14736&lt;/FONT&gt;&lt;/TD&gt;&lt;TD&gt;&lt;FONT color="#FF0000"&gt;14736&lt;/FONT&gt;&lt;/TD&gt;&lt;TD&gt;14737&lt;/TD&gt;&lt;TD&gt;14737&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;TD&gt;&lt;FONT color="#FF0000"&gt;14736&lt;/FONT&gt;&lt;/TD&gt;&lt;TD&gt;14738&lt;/TD&gt;&lt;TD&gt;14737&lt;/TD&gt;&lt;TD&gt;14738&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;I simply assigned e&lt;EM&gt;date0&lt;/EM&gt; to &lt;EM&gt;edate&amp;nbsp;&lt;/EM&gt;and &lt;EM&gt;ddate0&lt;/EM&gt; to&amp;nbsp;&lt;EM&gt;ddate&lt;/EM&gt;, and still managed to get the wrong values. I did some experiments with simple numeric values and couldn't reproduce the same error. Maybe it has to do with the special date class and some memory address problem?&lt;/P&gt;&lt;/DIV&gt;&lt;DIV class=""&gt;&amp;nbsp;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Thu, 14 Apr 2022 11:53:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Software-for-Learning/Potential-bug-with-assigning-numeric-date-values-to-variables/m-p/807776#M465</guid>
      <dc:creator>libokj</dc:creator>
      <dc:date>2022-04-14T11:53:38Z</dc:date>
    </item>
    <item>
      <title>Re: Potential bug with assigning numeric date values to variables</title>
      <link>https://communities.sas.com/t5/SAS-Software-for-Learning/Potential-bug-with-assigning-numeric-date-values-to-variables/m-p/807779#M466</link>
      <description>&lt;P&gt;Not seeing it:&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;data task2;
    edate=0;
    ddate=0;
run;
data task3;
    set task2;
	day0 = mdy(05, 07, 00);
	edate = edate + day0;
	ddate = ddate + day0;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please provide (a portion of) your actual data set&amp;nbsp;csp.task2 for us to use by following &lt;A href="https://blogs.sas.com/content/sastraining/2016/03/11/jedi-sas-tricks-data-to-data-step-macro/" target="_self"&gt;these instructions&lt;/A&gt;. DO NOT PROVIDE THE DATA IN ANY OTHER WAY.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 14 Apr 2022 12:01:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Software-for-Learning/Potential-bug-with-assigning-numeric-date-values-to-variables/m-p/807779#M466</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2022-04-14T12:01:45Z</dc:date>
    </item>
    <item>
      <title>Re: Potential bug with assigning numeric date values to variables</title>
      <link>https://communities.sas.com/t5/SAS-Software-for-Learning/Potential-bug-with-assigning-numeric-date-values-to-variables/m-p/807781#M467</link>
      <description>You are complicating the places where something can go wrong by using a two-digit year.  See if the problem remains after specifying a four-digit year in the MDY function.</description>
      <pubDate>Thu, 14 Apr 2022 12:12:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Software-for-Learning/Potential-bug-with-assigning-numeric-date-values-to-variables/m-p/807781#M467</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2022-04-14T12:12:14Z</dc:date>
    </item>
    <item>
      <title>Re: Potential bug with assigning numeric date values to variables</title>
      <link>https://communities.sas.com/t5/SAS-Software-for-Learning/Potential-bug-with-assigning-numeric-date-values-to-variables/m-p/807826#M468</link>
      <description>&lt;P&gt;If Edate or Ddate are supposed to be date values then why would be adding another date to them???&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;What do you expect to get for 01Jan1960 + 07May2000? That is what this does when edate is 0&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=""&gt;edate + day0;&lt;BR /&gt;or&amp;nbsp;similar&amp;nbsp;for&amp;nbsp;intnx&lt;BR /&gt;('day',day0,edate)&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;A value of 0 when treated as a date is 01JAN1960 which is the base for SAS dates. So when you add anything to that it is like 0+ x, which yields x. So you get the date from X.&lt;/P&gt;
&lt;P&gt;You don't describe what you are actually trying to do so can't make suggestions.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Hint: ASSIGN date formats like DATE9. or YYMMDD10. to any variable that is supposed to be a date.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Read this:&lt;/P&gt;
&lt;P&gt;&lt;A href="https://communities.sas.com/t5/SAS-Communities-Library/Working-with-Dates-and-Times-in-SAS-Tutorial/ta-p/424354" target="_blank"&gt;https://communities.sas.com/t5/SAS-Communities-Library/Working-with-Dates-and-Times-in-SAS-Tutorial/ta-p/424354&lt;/A&gt; has a PDF with much information about dates.&lt;/P&gt;</description>
      <pubDate>Thu, 14 Apr 2022 14:25:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Software-for-Learning/Potential-bug-with-assigning-numeric-date-values-to-variables/m-p/807826#M468</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2022-04-14T14:25:16Z</dc:date>
    </item>
    <item>
      <title>Re: Potential bug with assigning numeric date values to variables</title>
      <link>https://communities.sas.com/t5/SAS-Software-for-Learning/Potential-bug-with-assigning-numeric-date-values-to-variables/m-p/807828#M469</link>
      <description>&lt;P&gt;What date did you mean to create by using ZERO as the YEAR value in the call to MDY() function?&amp;nbsp; SAS dates only work with dates after&amp;nbsp;January 1, 1582&amp;nbsp; It seems that SAS just assumes you meant the year 2000 instead of the value you actually passed.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;What values do EDATE and DDATE0 have in the input dataset?&lt;/P&gt;
&lt;P&gt;Your code is assuming it has a relative day value and not an actual date value.&amp;nbsp; So something like 21 which would mean 21 days since some epoch date.&amp;nbsp; &amp;nbsp;Otherwise adding EDATE to DAY0 makes no sense.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Try checking out the range of values in the data.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc means n min max range  data = csp.task2;
  var edate ddate0 ;&lt;BR /&gt;  format edate ddate0 ;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 14 Apr 2022 14:41:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Software-for-Learning/Potential-bug-with-assigning-numeric-date-values-to-variables/m-p/807828#M469</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2022-04-14T14:41:00Z</dc:date>
    </item>
    <item>
      <title>Re: Potential bug with assigning numeric date values to variables</title>
      <link>https://communities.sas.com/t5/SAS-Software-for-Learning/Potential-bug-with-assigning-numeric-date-values-to-variables/m-p/807863#M470</link>
      <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/422922"&gt;@libokj&lt;/a&gt;,&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;SAS date values (such as &lt;FONT face="courier new,courier"&gt;14737='07MAY2000'd&lt;/FONT&gt;) are indistinguishable from any other numeric values (14,737.00 dollars, miles, etc.).&amp;nbsp;&lt;/LI&gt;
&lt;LI&gt;Diagnostic &lt;A href="https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/lestmtsref/n1spe7nmkmi7ywn175002rof97fv.htm" target="_blank" rel="noopener"&gt;PUT statements&lt;/A&gt; often help to explain the occurrence of unexpected values.&lt;/LI&gt;
&lt;LI&gt;When it comes to "bizarre" phenomena, don't trust anything but SAS formats revealing the binary content of a variable, e.g., the &lt;A href="https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/leforinforref/n0ueabv26pr2fwn19uxk2f4bf10y.htm" target="_blank" rel="noopener"&gt;HEX16. format&lt;/A&gt; for numeric values (and the &lt;A href="https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/leforinforref/p1h8xtl50tpzthn1u8kp0sji8f60.htm" target="_blank" rel="noopener"&gt;$HEX&lt;EM&gt;w&lt;/EM&gt;. format&lt;/A&gt; for character values).&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Example:&lt;/P&gt;
&lt;PRE&gt;data have;
edate=-1e-11;
ddate=0;
run;

data want;
set have;
day0 = mdy(05, 07, 00);
&lt;FONT color="#3366FF"&gt;&lt;STRONG&gt;put 'Before:' /
    (edate ddate day0) (=best22.) /
    (edate ddate day0) (=hex16.) /;&lt;/STRONG&gt;&lt;/FONT&gt;
edate = edate + day0;
ddate = ddate + day0;
&lt;FONT color="#3366FF"&gt;&lt;STRONG&gt;put 'After:' /
    (edate ddate) (=best22.) /
    (edate ddate) (=hex16.);&lt;/STRONG&gt;&lt;/FONT&gt;
run;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The PUT statements write to the log:&lt;/P&gt;
&lt;PRE&gt;Before:
edate=-1E-11 ddate=0 day0=14737
edate=BDA5FD7FE1796495 ddate=0000000000000000 day0=40CCC88000000000

After:
edate=14736.9999999999 ddate=14737
edate=40CCC87FFFFFFFFB ddate=40CCC88000000000&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 14 Apr 2022 16:31:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Software-for-Learning/Potential-bug-with-assigning-numeric-date-values-to-variables/m-p/807863#M470</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2022-04-14T16:31:56Z</dc:date>
    </item>
    <item>
      <title>Re: Potential bug with assigning numeric date values to variables</title>
      <link>https://communities.sas.com/t5/SAS-Software-for-Learning/Potential-bug-with-assigning-numeric-date-values-to-variables/m-p/807873#M471</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/32733"&gt;@FreelanceReinh&lt;/a&gt;&amp;nbsp;wrote:
&lt;UL&gt;
&lt;LI&gt;When it comes to "bizarre" phenomena, don't trust anything but SAS formats revealing the binary content of a variable, e.g., the &lt;A href="https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/leforinforref/n0ueabv26pr2fwn19uxk2f4bf10y.htm" target="_blank" rel="noopener"&gt;HEX16. format&lt;/A&gt; for numeric values (and the &lt;A href="https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/leforinforref/p1h8xtl50tpzthn1u8kp0sji8f60.htm" target="_blank" rel="noopener"&gt;$HEX&lt;EM&gt;w&lt;/EM&gt;. format&lt;/A&gt; for character values).&lt;/LI&gt;
&lt;/UL&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Great advice! I am going to bookmark this post!&lt;/P&gt;</description>
      <pubDate>Thu, 14 Apr 2022 16:53:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Software-for-Learning/Potential-bug-with-assigning-numeric-date-values-to-variables/m-p/807873#M471</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2022-04-14T16:53:30Z</dc:date>
    </item>
    <item>
      <title>Re: Potential bug with assigning numeric date values to variables</title>
      <link>https://communities.sas.com/t5/SAS-Software-for-Learning/Potential-bug-with-assigning-numeric-date-values-to-variables/m-p/807882#M472</link>
      <description>&lt;P&gt;Thank you all for such quick replies. It's my first time posting here, and I have already found the&amp;nbsp;SAS Community so friendly and helpful.&lt;/P&gt;&lt;P&gt;I did leave out some important details:&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;&lt;STRONG&gt;edate&lt;/STRONG&gt; and &lt;STRONG&gt;ddate&amp;nbsp;&lt;/STRONG&gt;are numeric (integers). They represent days elapsed from day zero in a clinical trial, so simply 0, 1, 2, etc.&lt;/LI&gt;&lt;LI&gt;I was trying to transform these integer "dates" into actual date objects by adding the date for the day zero (7 May 2000), which I believe in SAS is equivalent to a numeric.&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;By reading&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/32733"&gt;@FreelanceReinh&lt;/a&gt;'s post, I realized that this could be a problem with rounding. I'm new to SAS and found it strange that SAS "does not" differentiate between int and float types and instead only has "numeric". Thanks to your post, I've learned that there are ways to debug SAS like in other languages.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 14 Apr 2022 17:24:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Software-for-Learning/Potential-bug-with-assigning-numeric-date-values-to-variables/m-p/807882#M472</guid>
      <dc:creator>libokj</dc:creator>
      <dc:date>2022-04-14T17:24:22Z</dc:date>
    </item>
    <item>
      <title>Re: Potential bug with assigning numeric date values to variables</title>
      <link>https://communities.sas.com/t5/SAS-Software-for-Learning/Potential-bug-with-assigning-numeric-date-values-to-variables/m-p/807891#M473</link>
      <description>&lt;P&gt;SAS datasets have two data types.&amp;nbsp; Fixed length character strings and floating point numbers.&lt;/P&gt;
&lt;P&gt;The DATE formats will ignore fractions of a day.&lt;/P&gt;
&lt;PRE&gt;822   data _null_;
823     now=today();
824     do offset=0,1,-1,-0.5,+0.5 ;
825       new=now+offset;
826       put offset= new= new= date9.;
827     end;
828   run;

offset=0 new=22749 new=14APR2022
offset=1 new=22750 new=15APR2022
offset=-1 new=22748 new=13APR2022
offset=-0.5 new=22748.5 new=13APR2022
offset=0.5 new=22749.5 new=14APR2022
&lt;/PRE&gt;</description>
      <pubDate>Thu, 14 Apr 2022 18:20:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Software-for-Learning/Potential-bug-with-assigning-numeric-date-values-to-variables/m-p/807891#M473</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2022-04-14T18:20:17Z</dc:date>
    </item>
    <item>
      <title>Re: Potential bug with assigning numeric date values to variables</title>
      <link>https://communities.sas.com/t5/SAS-Software-for-Learning/Potential-bug-with-assigning-numeric-date-values-to-variables/m-p/807893#M474</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt; Before:
 edate=0 ddate=0 day0=14737
 edate=0000000000000000 ddate=0000000000000000 day0=40CCC88000000000
 After:
 edate=14737 ddate=14737
 edate=40CCC88000000000 ddate=40CCC88000000000&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Oops... I think that didn't turn out the way you or I expected. Their HEX and DEC codes are identical, but in the saved dataset&amp;nbsp;&lt;CODE class=""&gt;edate&lt;/CODE&gt; magically becomes 14736 still. Could it really be a bug?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 14 Apr 2022 18:25:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Software-for-Learning/Potential-bug-with-assigning-numeric-date-values-to-variables/m-p/807893#M474</guid>
      <dc:creator>libokj</dc:creator>
      <dc:date>2022-04-14T18:25:27Z</dc:date>
    </item>
    <item>
      <title>Re: Potential bug with assigning numeric date values to variables</title>
      <link>https://communities.sas.com/t5/SAS-Software-for-Learning/Potential-bug-with-assigning-numeric-date-values-to-variables/m-p/807894#M475</link>
      <description>Thank you for the information. I was aware of this feature. I did try to output the variables in HEX as @FreelanceReinhard suggested, and they were correct in the PUT output, but in the saved dataset the dates still have the same problem.</description>
      <pubDate>Thu, 14 Apr 2022 18:40:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Software-for-Learning/Potential-bug-with-assigning-numeric-date-values-to-variables/m-p/807894#M475</guid>
      <dc:creator>libokj</dc:creator>
      <dc:date>2022-04-14T18:40:21Z</dc:date>
    </item>
    <item>
      <title>Re: Potential bug with assigning numeric date values to variables</title>
      <link>https://communities.sas.com/t5/SAS-Software-for-Learning/Potential-bug-with-assigning-numeric-date-values-to-variables/m-p/807896#M476</link>
      <description>&lt;P&gt;EDATE in that print out is&amp;nbsp;14737.&amp;nbsp; You can tell because it has the exact same HEX representation as DAY0.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;How are you checking the new value.&lt;/P&gt;
&lt;P&gt;How is the variable EDATE defined in the saved SAS dataset.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Did you ask SAS to eliminate some of the least significant bytes of the floating point value by asking it to only store some of the 8 bytes that are required for 64-bit floating point numbers?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;840   data test;
841     length date3 3 date8 8;
842     date3=today();
843     date8=today();
844     format date: date9.;
845     put date3= date8= ;
846   run;

date3=14APR2022 date8=14APR2022
NOTE: The data set WORK.TEST has 1 observations and 2 variables.
NOTE: DATA statement used (Total process time):
      real time           0.00 seconds
      cpu time            0.00 seconds


847
848   data _null_;
849     set test;
850     put date3= date8= ;
851   run;

date3=13APR2022 date8=14APR2022
NOTE: There were 1 observations read from the data set WORK.TEST.
NOTE: DATA statement used (Total process time):
      real time           0.00 seconds
      cpu time            0.00 seconds
&lt;/PRE&gt;</description>
      <pubDate>Thu, 14 Apr 2022 18:46:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Software-for-Learning/Potential-bug-with-assigning-numeric-date-values-to-variables/m-p/807896#M476</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2022-04-14T18:46:50Z</dc:date>
    </item>
    <item>
      <title>Re: Potential bug with assigning numeric date values to variables</title>
      <link>https://communities.sas.com/t5/SAS-Software-for-Learning/Potential-bug-with-assigning-numeric-date-values-to-variables/m-p/807897#M477</link>
      <description>I checked the saved dataset by both SAS data viewer and proc print. In decimal edate becomes 14736, and in HEX 40CCC80000000000. So in the process of saving the transformed variables to the dataset, their values did change.</description>
      <pubDate>Thu, 14 Apr 2022 18:52:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Software-for-Learning/Potential-bug-with-assigning-numeric-date-values-to-variables/m-p/807897#M477</guid>
      <dc:creator>libokj</dc:creator>
      <dc:date>2022-04-14T18:52:39Z</dc:date>
    </item>
    <item>
      <title>Re: Potential bug with assigning numeric date values to variables</title>
      <link>https://communities.sas.com/t5/SAS-Software-for-Learning/Potential-bug-with-assigning-numeric-date-values-to-variables/m-p/807898#M478</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/422922"&gt;@libokj&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;I checked the saved dataset by both SAS data viewer and proc print. In decimal edate becomes 14736, and in HEX 40CCC80000000000. So in the process of saving the transformed variables to the dataset, their values did change.&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Yes, this will be the effect if EDATE has the (insufficient) length &lt;STRONG&gt;3&lt;/STRONG&gt;. &lt;EM&gt;Four&lt;/EM&gt; bytes are the minimum for SAS date values.&lt;/P&gt;</description>
      <pubDate>Thu, 14 Apr 2022 18:58:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Software-for-Learning/Potential-bug-with-assigning-numeric-date-values-to-variables/m-p/807898#M478</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2022-04-14T18:58:08Z</dc:date>
    </item>
    <item>
      <title>Re: Potential bug with assigning numeric date values to variables</title>
      <link>https://communities.sas.com/t5/SAS-Software-for-Learning/Potential-bug-with-assigning-numeric-date-values-to-variables/m-p/807899#M479</link>
      <description>Thank you! Precision was indeed the problem. I'm new to SAS and quite unfamiliar with its data structures and features. Specifying length in the data step for edate and ddate before the rewrite solved the problem.</description>
      <pubDate>Thu, 14 Apr 2022 18:59:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Software-for-Learning/Potential-bug-with-assigning-numeric-date-values-to-variables/m-p/807899#M479</guid>
      <dc:creator>libokj</dc:creator>
      <dc:date>2022-04-14T18:59:24Z</dc:date>
    </item>
    <item>
      <title>Re: Potential bug with assigning numeric date values to variables</title>
      <link>https://communities.sas.com/t5/SAS-Software-for-Learning/Potential-bug-with-assigning-numeric-date-values-to-variables/m-p/807901#M480</link>
      <description>Quick question tho: the official documentation says the default length in bytes for "numeric" is 8. If that's the case, there's no way that this could have happened.</description>
      <pubDate>Thu, 14 Apr 2022 19:09:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Software-for-Learning/Potential-bug-with-assigning-numeric-date-values-to-variables/m-p/807901#M480</guid>
      <dc:creator>libokj</dc:creator>
      <dc:date>2022-04-14T19:09:59Z</dc:date>
    </item>
    <item>
      <title>Re: Potential bug with assigning numeric date values to variables</title>
      <link>https://communities.sas.com/t5/SAS-Software-for-Learning/Potential-bug-with-assigning-numeric-date-values-to-variables/m-p/807903#M481</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/422922"&gt;@libokj&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;Quick question tho: the official documentation says the default length in bytes for "numeric" is 8. If that's the case, there's no way that this could have happened.&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;The default length for a&amp;nbsp; variable read from an existing dataset is the length that it used in that dataset.&lt;/P&gt;</description>
      <pubDate>Thu, 14 Apr 2022 19:14:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Software-for-Learning/Potential-bug-with-assigning-numeric-date-values-to-variables/m-p/807903#M481</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2022-04-14T19:14:26Z</dc:date>
    </item>
    <item>
      <title>Re: Potential bug with assigning numeric date values to variables</title>
      <link>https://communities.sas.com/t5/SAS-Software-for-Learning/Potential-bug-with-assigning-numeric-date-values-to-variables/m-p/807904#M482</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/422922"&gt;@libokj&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;Thank you! Precision was indeed the problem. I'm new to SAS and quite unfamiliar with its data structures and features. Specifying length in the data step for edate and ddate before the rewrite solved the problem.&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;A lot of uses are confused by LENGTH.&amp;nbsp; The conflate the LENGTH (number of bytes stored in the SAS datasets) with the WIDTH of the format used to DISPLAY the value as text.&lt;/P&gt;</description>
      <pubDate>Thu, 14 Apr 2022 19:16:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Software-for-Learning/Potential-bug-with-assigning-numeric-date-values-to-variables/m-p/807904#M482</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2022-04-14T19:16:18Z</dc:date>
    </item>
    <item>
      <title>Re: Potential bug with assigning numeric date values to variables</title>
      <link>https://communities.sas.com/t5/SAS-Software-for-Learning/Potential-bug-with-assigning-numeric-date-values-to-variables/m-p/807907#M483</link>
      <description>Thanks. That's good to know... That's a cheap way to save system resources tho. I think in most languages data read from files are initialized with the default precision.</description>
      <pubDate>Thu, 14 Apr 2022 19:21:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Software-for-Learning/Potential-bug-with-assigning-numeric-date-values-to-variables/m-p/807907#M483</guid>
      <dc:creator>libokj</dc:creator>
      <dc:date>2022-04-14T19:21:33Z</dc:date>
    </item>
    <item>
      <title>Re: Potential bug with assigning numeric date values to variables</title>
      <link>https://communities.sas.com/t5/SAS-Software-for-Learning/Potential-bug-with-assigning-numeric-date-values-to-variables/m-p/807910#M484</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/422922"&gt;@libokj&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;Thanks. That's good to know... That's a cheap way to save system resources tho. I think in most languages data read from files are initialized with the default precision.&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Precision has nothing to do with it.&lt;/P&gt;
&lt;P&gt;SAS will also default the type and storage length of a variable if you do not explicitly define it.&lt;/P&gt;
&lt;P&gt;SAS only has two data types.&amp;nbsp; Fixed length character strings and floating point numbers.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So for your EDATE variable to have been created with a storage length of 3 (or 2 if running on IBM hardware) then someone had to explicitly tell SAS to throw away the rest of the value when writing it to the disk by issuing a LENGTH statement.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;A length of 3 might make sense for EDATE when it was a relative day variable.&amp;nbsp; But you change the size of the values you were storing by a couple of orders of magnitude by converting it to the number of days since 1960 instead.&lt;/P&gt;</description>
      <pubDate>Thu, 14 Apr 2022 19:39:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Software-for-Learning/Potential-bug-with-assigning-numeric-date-values-to-variables/m-p/807910#M484</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2022-04-14T19:39:35Z</dc:date>
    </item>
  </channel>
</rss>

