<?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 dates in Statistical Procedures</title>
    <link>https://communities.sas.com/t5/Statistical-Procedures/Difference-between-dates/m-p/191652#M10148</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;post sample from the have dataset&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 21 Jan 2015 10:59:39 GMT</pubDate>
    <dc:creator>mohamed_zaki</dc:creator>
    <dc:date>2015-01-21T10:59:39Z</dc:date>
    <item>
      <title>Difference between dates</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Difference-between-dates/m-p/191651#M10147</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi&lt;/P&gt;&lt;P&gt;I have imported an excel file containing two dates columns, formated as yymmdd&lt;/P&gt;&lt;P&gt;I am trying to find the difference between these two columns&lt;/P&gt;&lt;P&gt;I used the code below but it is returning some strange results&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P class="p1"&gt;&lt;SPAN class="s1"&gt;&lt;STRONG&gt;data&lt;/STRONG&gt;&lt;/SPAN&gt; want;&lt;/P&gt;&lt;P class="p1"&gt;&lt;SPAN class="s2"&gt;set&lt;/SPAN&gt; have;&lt;/P&gt;&lt;P class="p1"&gt;&lt;SPAN class="s2"&gt;format&lt;/SPAN&gt; regtime start_date &lt;SPAN class="s3"&gt;yymmdd10.&lt;/SPAN&gt;;&lt;/P&gt;&lt;P class="p1"&gt;NumDays = intck( &lt;SPAN class="s4"&gt;'day'&lt;/SPAN&gt;, start_date, regtime );&lt;/P&gt;&lt;P class="p2"&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;&lt;SPAN class="s5"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P class="p2"&gt;&lt;SPAN class="s5"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P class="p2"&gt;&lt;SPAN class="s5"&gt;Any help is appreciated&lt;/SPAN&gt;&lt;/P&gt;&lt;P class="p2"&gt;&lt;SPAN class="s5"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P class="p2"&gt;&lt;SPAN class="s5"&gt;Regards&lt;/SPAN&gt;&lt;/P&gt;&lt;P class="p2"&gt;&lt;SPAN class="s5"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 21 Jan 2015 10:08:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Difference-between-dates/m-p/191651#M10147</guid>
      <dc:creator>ammarhm</dc:creator>
      <dc:date>2015-01-21T10:08:15Z</dc:date>
    </item>
    <item>
      <title>Re: Difference between dates</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Difference-between-dates/m-p/191652#M10148</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;post sample from the have dataset&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 21 Jan 2015 10:59:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Difference-between-dates/m-p/191652#M10148</guid>
      <dc:creator>mohamed_zaki</dc:creator>
      <dc:date>2015-01-21T10:59:39Z</dc:date>
    </item>
    <item>
      <title>Re: Difference between dates</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Difference-between-dates/m-p/191653#M10149</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Your CODE is Fine.&lt;/P&gt;&lt;P&gt;Better to see your example.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 21 Jan 2015 11:01:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Difference-between-dates/m-p/191653#M10149</guid>
      <dc:creator>KachiM</dc:creator>
      <dc:date>2015-01-21T11:01:54Z</dc:date>
    </item>
    <item>
      <title>Re: Difference between dates</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Difference-between-dates/m-p/191654#M10150</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I believe the strange result is because of the date format used.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;could you please convert the dates to date9. format and then use the intck function.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Jag&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 21 Jan 2015 11:15:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Difference-between-dates/m-p/191654#M10150</guid>
      <dc:creator>Jagadishkatam</dc:creator>
      <dc:date>2015-01-21T11:15:04Z</dc:date>
    </item>
    <item>
      <title>Re: Difference between dates</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Difference-between-dates/m-p/191655#M10151</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You don't actually need that function.&amp;nbsp; If both of your variables are date variables, then they are stored as the number of days since a certain timepoint.&amp;nbsp; Therefore if you subtract one from the other you get the number of days between:&lt;/P&gt;&lt;P&gt;num_days = start_date - regtime;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;However, I also concur with the above posters, post example data as the term Regtime indicates that you are looking at a time variable not a date.&amp;nbsp; Or possible a date/time variable.&amp;nbsp; If so then just do:&lt;/P&gt;&lt;P&gt;num_days = start_date - datepart(regtime);&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 21 Jan 2015 11:29:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Difference-between-dates/m-p/191655#M10151</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2015-01-21T11:29:00Z</dc:date>
    </item>
    <item>
      <title>Re: Difference between dates</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Difference-between-dates/m-p/191656#M10152</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Here is a sample of the file&lt;/P&gt;&lt;P&gt;The variables are not formated as date in the Excel file but I thought it wouldn't be a problem as I am applying a date format in the SAS code then&lt;/P&gt;&lt;P&gt;As I mentioned, the date formate here is yymmdd&lt;/P&gt;&lt;P&gt;Thanks in advance&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 21 Jan 2015 18:37:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Difference-between-dates/m-p/191656#M10152</guid>
      <dc:creator>ammarhm</dc:creator>
      <dc:date>2015-01-21T18:37:11Z</dc:date>
    </item>
    <item>
      <title>Re: Difference between dates</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Difference-between-dates/m-p/191657#M10153</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I think it is the way that you are importing these.&lt;/P&gt;&lt;P&gt;If you just use a simple proc import, it will import these as numeric and not as SAS dates.&lt;/P&gt;&lt;P&gt;SAS dates are also numeric, but they reference the number of days since 1/1/1960.&lt;/P&gt;&lt;P&gt;What you are getting are the numeric values&lt;/P&gt;&lt;P&gt;Obs&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Start_date&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; regtime&lt;/P&gt;&lt;P&gt;&amp;nbsp; 1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 120305&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 140224&lt;BR /&gt;&amp;nbsp; 2&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 120319&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 140224&lt;BR /&gt;&amp;nbsp; 3&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 120227&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 140224&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You need to convert these to SAS dates or import them as SAS dates.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;To convert them to SAS dates, you can do something like&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P class="p1"&gt;&lt;SPAN class="s1"&gt;&lt;STRONG&gt;data&lt;/STRONG&gt;&lt;/SPAN&gt; want;&lt;/P&gt;&lt;P class="p1"&gt;&lt;SPAN class="s2"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; set&lt;/SPAN&gt; have;&lt;/P&gt;&lt;P class="p1"&gt;&lt;/P&gt;&lt;P class="p1"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; sas_start_date = input(compress(put(start_date,best8.)),yymmdd6.);&lt;/P&gt;&lt;P class="p1"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; sas_regtime = input(compress(put(stat_date,best8.)),yymmdd6.);&lt;/P&gt;&lt;P class="p1"&gt;&lt;/P&gt;&lt;P class="p1"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; NumDays = sas_regtime - sas_start_date;&lt;/P&gt;&lt;P class="p2"&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;&lt;SPAN class="s5"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 21 Jan 2015 19:01:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Difference-between-dates/m-p/191657#M10153</guid>
      <dc:creator>BurntDirt</dc:creator>
      <dc:date>2015-01-21T19:01:05Z</dc:date>
    </item>
    <item>
      <title>Re: Difference between dates</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Difference-between-dates/m-p/191658#M10154</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Yes, as BurntDirt has mentioned those are just numbers, and it is just guessing what they represent, is 120305 = 12Mar05, or 05Mar12 or something else??&amp;nbsp; Also little tip, don't use proc import as it basically guesses what you want to do.&amp;nbsp; There are many ways to get data in, I would advise that flat text file delimited, e.g. CSV, is best.&amp;nbsp; Then write a datastep import program specifically tailored to the data you know best.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 21 Jan 2015 19:28:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Difference-between-dates/m-p/191658#M10154</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2015-01-21T19:28:52Z</dc:date>
    </item>
    <item>
      <title>Re: Difference between dates</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Difference-between-dates/m-p/191659#M10155</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;A __default_attr="9792" __jive_macro_name="user" class="jive_macro jive_macro_user" data-objecttype="3" href="https://communities.sas.com/"&gt;&lt;/A&gt;&lt;/P&gt;&lt;P&gt;The date format applied has no influence on the result returned by the intck() function as the function uses the internal numeric value.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 21 Jan 2015 20:29:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Difference-between-dates/m-p/191659#M10155</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2015-01-21T20:29:03Z</dc:date>
    </item>
  </channel>
</rss>

