<?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 difference between date in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/difference-between-date/m-p/790026#M81432</link>
    <description>&lt;P&gt;&lt;SPAN&gt;This code has worked for me in the past, but not today. Can you please help suggesting what I'm doing wrong?&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;I have this error in the log&amp;nbsp;NOTE: Invalid argument to function INTCK('days',21311,20061221) at line 498 column 16.&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data diff;&lt;/P&gt;
&lt;P&gt;set penality;&lt;BR /&gt;by Number;&lt;/P&gt;
&lt;P&gt;days_between = intck('days',Penalty_Date,lag(Penalty_Date));&lt;/P&gt;
&lt;P&gt;if first.Number then call missing(days_between);&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;</description>
    <pubDate>Thu, 13 Jan 2022 16:45:56 GMT</pubDate>
    <dc:creator>sasphd</dc:creator>
    <dc:date>2022-01-13T16:45:56Z</dc:date>
    <item>
      <title>difference between date</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/difference-between-date/m-p/790026#M81432</link>
      <description>&lt;P&gt;&lt;SPAN&gt;This code has worked for me in the past, but not today. Can you please help suggesting what I'm doing wrong?&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;I have this error in the log&amp;nbsp;NOTE: Invalid argument to function INTCK('days',21311,20061221) at line 498 column 16.&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data diff;&lt;/P&gt;
&lt;P&gt;set penality;&lt;BR /&gt;by Number;&lt;/P&gt;
&lt;P&gt;days_between = intck('days',Penalty_Date,lag(Penalty_Date));&lt;/P&gt;
&lt;P&gt;if first.Number then call missing(days_between);&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;</description>
      <pubDate>Thu, 13 Jan 2022 16:45:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/difference-between-date/m-p/790026#M81432</guid>
      <dc:creator>sasphd</dc:creator>
      <dc:date>2022-01-13T16:45:56Z</dc:date>
    </item>
    <item>
      <title>Re: difference between date</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/difference-between-date/m-p/790030#M81433</link>
      <description>The result of lag(Penalty_Date) is 20061221, which I think is an ERROR because it is beyond the range that can be handled by SAS date values.&lt;BR /&gt;Can you provide the actual data for the OBS before and after this?</description>
      <pubDate>Thu, 13 Jan 2022 16:57:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/difference-between-date/m-p/790030#M81433</guid>
      <dc:creator>japelin</dc:creator>
      <dc:date>2022-01-13T16:57:32Z</dc:date>
    </item>
    <item>
      <title>Re: difference between date</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/difference-between-date/m-p/790031#M81434</link>
      <description>&lt;P&gt;A date value of 20061221 (20 &lt;EM&gt;million&lt;/EM&gt; days after 1960-01-01) falls somewhere in the late 55th millenium, so the function can't handle that and tells you so.&lt;/P&gt;
&lt;P&gt;Looks like someone entered a date in a silly way.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Also, since SAS dates are counts of days anyway, your formula can be simplified as&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;days_between = lag(Penalty_Date) - Penalty_Date;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;which will be faster than the function call.&lt;/P&gt;</description>
      <pubDate>Thu, 13 Jan 2022 17:00:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/difference-between-date/m-p/790031#M81434</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2022-01-13T17:00:28Z</dc:date>
    </item>
    <item>
      <title>Re: difference between date</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/difference-between-date/m-p/790032#M81435</link>
      <description>&lt;P&gt;INTCK requires SAS date arguments.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;20161221 is not a SAS date.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here's a great, but longer and in depth, reference for dates and times in SAS&lt;BR /&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;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But since you're referring to the same variable that also doesn't make logical sense. Assuming your date is an actual SAS date, numeric with a date format then you can use the DIF function instead. If not, I'd convert it first and then use the DIF approach. If you need to convert it to a SAS date from a character it would be:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;date = input(penalty_date, yymmdd10.);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Then:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data diff;

set penality;
by Number;

days_between = dif(penalty_date);

if first.Number then call missing(days_between);

run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;FYI - please use code blocks in future posts to have your code show up cleanly and formatted.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/4327"&gt;@sasphd&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;&lt;SPAN&gt;This code has worked for me in the past, but not today. Can you please help suggesting what I'm doing wrong?&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;I have this error in the log&amp;nbsp;NOTE: Invalid argument to function INTCK('days',21311,20061221) at line 498 column 16.&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data diff;&lt;/P&gt;
&lt;P&gt;set penality;&lt;BR /&gt;by Number;&lt;/P&gt;
&lt;P&gt;days_between = intck('days',Penalty_Date,lag(Penalty_Date));&lt;/P&gt;
&lt;P&gt;if first.Number then call missing(days_between);&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 13 Jan 2022 17:01:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/difference-between-date/m-p/790032#M81435</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2022-01-13T17:01:33Z</dc:date>
    </item>
    <item>
      <title>Re: difference between date</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/difference-between-date/m-p/790067#M81439</link>
      <description>&lt;P&gt;hello,&amp;nbsp;&lt;/P&gt;
&lt;P&gt;it seems not working. this is a sample of my data&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data penality;                     
   input Number $ penalty_date; 
       format Penalty_Date yymmdd10.;
   datalines;          
1 20061221   
1 20180507 
2 20140710  
2 20171002
;        


data diff;

set penality;
by Number;

days_between = dif(penalty_date);

if first.Number then call missing(days_between);

run; &lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;this is the output&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="sasphd_0-1642106076494.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/67386i842DFD48526CA2E6/image-size/medium?v=v2&amp;amp;px=400" role="button" title="sasphd_0-1642106076494.png" alt="sasphd_0-1642106076494.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 13 Jan 2022 20:34:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/difference-between-date/m-p/790067#M81439</guid>
      <dc:creator>sasphd</dc:creator>
      <dc:date>2022-01-13T20:34:53Z</dc:date>
    </item>
    <item>
      <title>Re: difference between date</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/difference-between-date/m-p/790068#M81440</link>
      <description>&lt;P&gt;You do realize that your first data step doesn't generate valid data?&lt;/P&gt;
&lt;P&gt;That's the reason. Fixing that so that &lt;STRONG&gt;penalty_date is a SAS date&lt;/STRONG&gt;, which I saved into a new variable makes it work perfectly fine.&amp;nbsp;&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 penality;                     
   input Number $ penalty_date ; 

   datalines;          
1 20061221   
1 20180507 
2 20140710  
2 20171002
;        


data penality2;
set penality;
                   

penalty_sas_date = input(put(penalty_date, 8.), yymmdd10.);
format penalty_sas_date yymmdd10.;
run;

data diff;

set penality2;
by Number;

days_between = dif(penalty_sas_date);

if first.Number then call missing(days_between);

run; &lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 13 Jan 2022 20:43:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/difference-between-date/m-p/790068#M81440</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2022-01-13T20:43:23Z</dc:date>
    </item>
  </channel>
</rss>

