<?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: Difference between two dates YYYYMMDD format date9. in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Difference-between-two-dates-YYYYMMDD-format-date9/m-p/437557#M108975</link>
    <description>&lt;P&gt;Data looks like this;&lt;/P&gt;&lt;P&gt;start&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;end&lt;/P&gt;&lt;P&gt;20100313&amp;nbsp; &amp;nbsp; &amp;nbsp; 20141231&lt;/P&gt;&lt;P&gt;20101127&amp;nbsp; &amp;nbsp; &amp;nbsp; 20160421&lt;/P&gt;&lt;P&gt;20091021&amp;nbsp; &amp;nbsp; &amp;nbsp; 20160519&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;and you had tried&amp;nbsp;&lt;/P&gt;&lt;PRE class=" language-sas"&gt;&lt;CODE class="  language-sas"&gt;&lt;SPAN class="token function"&gt;month&lt;/SPAN&gt;&lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt; &lt;SPAN class="token function"&gt;intck&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt;&lt;SPAN class="token string"&gt;'month'&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;,&lt;/SPAN&gt; start&lt;SPAN class="token punctuation"&gt;,&lt;/SPAN&gt; end&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;So this can be assumed you need difference in months.&lt;/P&gt;&lt;P&gt;And the above did not work so&amp;nbsp;both the variable start and end are not numeric or one of them not numeric.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;1. Please identify the non-numeric type data first and change it to numeric data type using format yymmdd8.&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; e.g.1. if start is charecter then do as following&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; start1=input(start,yymmdd8.);&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; e.g.1. if end is charecter then do as following&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; end1=input(end,yymmdd8.);&lt;/P&gt;&lt;P&gt;2. Then try the intck function for the difference.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Please note I have used a different variable while changing datatype in the example.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Please let us know if it helped you.&lt;/P&gt;</description>
    <pubDate>Thu, 15 Feb 2018 13:17:13 GMT</pubDate>
    <dc:creator>Satish_Parida</dc:creator>
    <dc:date>2018-02-15T13:17:13Z</dc:date>
    <item>
      <title>Difference between two dates YYYYMMDD format date9.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Difference-between-two-dates-YYYYMMDD-format-date9/m-p/437494#M108940</link>
      <description>&lt;P&gt;Hello! I want to calculate the difference between two dates. The dates are displayed as YYYYMMDD and they are in format date9. I tried this;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;DATA m.want;
SET m.have;
day=end-start;
RUN;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;but it doesn't give the exact days between the dates. Is there another solution?&lt;/P&gt;</description>
      <pubDate>Thu, 15 Feb 2018 10:40:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Difference-between-two-dates-YYYYMMDD-format-date9/m-p/437494#M108940</guid>
      <dc:creator>hovliza</dc:creator>
      <dc:date>2018-02-15T10:40:53Z</dc:date>
    </item>
    <item>
      <title>Re: Difference between two dates YYYYMMDD format date9.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Difference-between-two-dates-YYYYMMDD-format-date9/m-p/437495#M108941</link>
      <description>&lt;P&gt;"&lt;SPAN&gt;The dates are displayed as YYYYMMDD and they are in format date9. I tried this"... Please show us some of your data, this does not make much sense?&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;The &lt;A href="http://documentation.sas.com/?docsetId=lefunctionsref&amp;amp;docsetTarget=p1md4mx2crzfaqn14va8kt7qvfhr.htm&amp;amp;docsetVersion=9.4&amp;amp;locale=da" target="_self"&gt;INTCK Function&lt;/A&gt; is usually the way to go here..&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 15 Feb 2018 10:43:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Difference-between-two-dates-YYYYMMDD-format-date9/m-p/437495#M108941</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2018-02-15T10:43:42Z</dc:date>
    </item>
    <item>
      <title>Re: Difference between two dates YYYYMMDD format date9.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Difference-between-two-dates-YYYYMMDD-format-date9/m-p/437499#M108944</link>
      <description>&lt;P&gt;Yes I tried this;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;DATA m.want;
SET m.have;
month= intck('month', start, end);
RUN;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;But that doesn't work..&lt;/P&gt;</description>
      <pubDate>Thu, 15 Feb 2018 10:49:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Difference-between-two-dates-YYYYMMDD-format-date9/m-p/437499#M108944</guid>
      <dc:creator>hovliza</dc:creator>
      <dc:date>2018-02-15T10:49:14Z</dc:date>
    </item>
    <item>
      <title>Re: Difference between two dates YYYYMMDD format date9.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Difference-between-two-dates-YYYYMMDD-format-date9/m-p/437500#M108945</link>
      <description>&lt;P&gt;It looks like this;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;start&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;end&lt;/P&gt;&lt;P&gt;20100313&amp;nbsp; &amp;nbsp; &amp;nbsp; 20141231&lt;/P&gt;&lt;P&gt;20101127&amp;nbsp; &amp;nbsp; &amp;nbsp; 20160421&lt;/P&gt;&lt;P&gt;20091021&amp;nbsp; &amp;nbsp; &amp;nbsp; 20160519&lt;/P&gt;</description>
      <pubDate>Thu, 15 Feb 2018 10:52:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Difference-between-two-dates-YYYYMMDD-format-date9/m-p/437500#M108945</guid>
      <dc:creator>hovliza</dc:creator>
      <dc:date>2018-02-15T10:52:45Z</dc:date>
    </item>
    <item>
      <title>Re: Difference between two dates YYYYMMDD format date9.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Difference-between-two-dates-YYYYMMDD-format-date9/m-p/437507#M108949</link>
      <description>&lt;P&gt;If you want the number of months between start and end, your code is correct.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you want the difference in days (which I assume), do like this&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input (start end)(:yymmdd10.);
format start end date9.;
datalines;
20100313 20141231
20101127 20160421
20091021 20160519
;

data want;
	set have;
	daysbetween=intck('day', start, end);
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 15 Feb 2018 11:08:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Difference-between-two-dates-YYYYMMDD-format-date9/m-p/437507#M108949</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2018-02-15T11:08:54Z</dc:date>
    </item>
    <item>
      <title>Re: Difference between two dates YYYYMMDD format date9.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Difference-between-two-dates-YYYYMMDD-format-date9/m-p/437508#M108950</link>
      <description>&lt;P&gt;Difference in terms of what?&amp;nbsp; Days, months, years?&amp;nbsp; For days a simple division is fine:&lt;/P&gt;
&lt;PRE&gt;data want;
  a="01feb2018"d;
  b="16Mar2018"d;
  days=b-a;
  format a b yymmdd10.;
run;&lt;/PRE&gt;
&lt;P&gt;For months and years intck is the better choice.&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 15 Feb 2018 11:11:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Difference-between-two-dates-YYYYMMDD-format-date9/m-p/437508#M108950</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2018-02-15T11:11:16Z</dc:date>
    </item>
    <item>
      <title>Re: Difference between two dates YYYYMMDD format date9.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Difference-between-two-dates-YYYYMMDD-format-date9/m-p/437509#M108951</link>
      <description>&lt;P&gt;Thanks! For the three differences it works. I have 107 persons, is there an easier way to put at the 107 persons in the datalines?&lt;/P&gt;</description>
      <pubDate>Thu, 15 Feb 2018 11:20:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Difference-between-two-dates-YYYYMMDD-format-date9/m-p/437509#M108951</guid>
      <dc:creator>hovliza</dc:creator>
      <dc:date>2018-02-15T11:20:49Z</dc:date>
    </item>
    <item>
      <title>Re: Difference between two dates YYYYMMDD format date9.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Difference-between-two-dates-YYYYMMDD-format-date9/m-p/437533#M108962</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/172388"&gt;@hovliza&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;Hello! I want to calculate the difference between two dates. The dates are displayed as YYYYMMDD and they are in format date9. I tried this;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;DATA m.want;
SET m.have;
day=end-start;
RUN;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;but it doesn't give the exact days between the dates. Is there another solution?&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Maxim 3: Know your data. One of your variables is not a SAS date value. Look at the types and display formats of end and start in m.have.&lt;/P&gt;
&lt;P&gt;Once you know your data, convert so both variables contain SAS date values.&lt;/P&gt;</description>
      <pubDate>Thu, 15 Feb 2018 12:16:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Difference-between-two-dates-YYYYMMDD-format-date9/m-p/437533#M108962</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2018-02-15T12:16:04Z</dc:date>
    </item>
    <item>
      <title>Re: Difference between two dates YYYYMMDD format date9.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Difference-between-two-dates-YYYYMMDD-format-date9/m-p/437557#M108975</link>
      <description>&lt;P&gt;Data looks like this;&lt;/P&gt;&lt;P&gt;start&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;end&lt;/P&gt;&lt;P&gt;20100313&amp;nbsp; &amp;nbsp; &amp;nbsp; 20141231&lt;/P&gt;&lt;P&gt;20101127&amp;nbsp; &amp;nbsp; &amp;nbsp; 20160421&lt;/P&gt;&lt;P&gt;20091021&amp;nbsp; &amp;nbsp; &amp;nbsp; 20160519&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;and you had tried&amp;nbsp;&lt;/P&gt;&lt;PRE class=" language-sas"&gt;&lt;CODE class="  language-sas"&gt;&lt;SPAN class="token function"&gt;month&lt;/SPAN&gt;&lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt; &lt;SPAN class="token function"&gt;intck&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt;&lt;SPAN class="token string"&gt;'month'&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;,&lt;/SPAN&gt; start&lt;SPAN class="token punctuation"&gt;,&lt;/SPAN&gt; end&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;So this can be assumed you need difference in months.&lt;/P&gt;&lt;P&gt;And the above did not work so&amp;nbsp;both the variable start and end are not numeric or one of them not numeric.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;1. Please identify the non-numeric type data first and change it to numeric data type using format yymmdd8.&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; e.g.1. if start is charecter then do as following&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; start1=input(start,yymmdd8.);&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; e.g.1. if end is charecter then do as following&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; end1=input(end,yymmdd8.);&lt;/P&gt;&lt;P&gt;2. Then try the intck function for the difference.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Please note I have used a different variable while changing datatype in the example.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Please let us know if it helped you.&lt;/P&gt;</description>
      <pubDate>Thu, 15 Feb 2018 13:17:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Difference-between-two-dates-YYYYMMDD-format-date9/m-p/437557#M108975</guid>
      <dc:creator>Satish_Parida</dc:creator>
      <dc:date>2018-02-15T13:17:13Z</dc:date>
    </item>
  </channel>
</rss>

