<?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: DATDIF Function - Format input help in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/DATDIF-Function-Format-input-help/m-p/419598#M103188</link>
    <description>&lt;P&gt;Is your value a numeric with the value of&amp;nbsp;170102. Or is it a date value of 20821 displayed with the SAS display format of yymmdd6.?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;SAS data values which are required for any of the date functions to work are days offset from 1 Jan 1960. So if you date 170102 is supposed to be 2 Jan 2017 then the numeric value would have to be 20821.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;BTW when working with SAS FORMAT has a very specific interpretation of a display, not the actual values.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If your value is numeric and ALL of them have 6 digits you can create a SAS date value for use with the date functions and date FORMATS with&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;newdatevar = input(put(datevar,6.),yymmdd6.);&lt;/P&gt;
&lt;P&gt;in a data step where datevar is your existing date variable and newdatevar is the SAS date valued variable.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The appearance of the newdatevar would be set with a format, either at use or assign a default format at creation with a line like:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;format newdatevar date9. ; &amp;lt;= displays date as 02JAN2017&lt;/P&gt;
&lt;P&gt;format newdatevar mmddyy10. ; &amp;lt;= displays date as 01/02/2017 or any of many date format choices.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The SAS formats are very flexible in that you can use a different format in different procedures to create different groupings of your date variables without creating new variables.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;A second hint: Using 2 digit years in this day an age is getting to be a poor practice. It is not obvious that 170102 is in 2017 or 1917.&lt;/P&gt;
&lt;P&gt;And when the date in question is 010203 which is month, day and year is a complete guess.&lt;/P&gt;</description>
    <pubDate>Fri, 08 Dec 2017 15:34:00 GMT</pubDate>
    <dc:creator>ballardw</dc:creator>
    <dc:date>2017-12-08T15:34:00Z</dc:date>
    <item>
      <title>DATDIF Function - Format input help</title>
      <link>https://communities.sas.com/t5/SAS-Programming/DATDIF-Function-Format-input-help/m-p/419587#M103186</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am trying to use the DATDIF function to retrieve the amount of actual days between two dates:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The dates I am working with are numeric and in the format eg. 170102 and 170320 (2nd&amp;nbsp;Jan 2017 and 20th Mar 2017).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am unsure of how to prep these dates such that when I input them into DATDIF it will be able to run properly.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any help is much appreciated,&lt;/P&gt;&lt;P&gt;Declan&lt;/P&gt;</description>
      <pubDate>Fri, 08 Dec 2017 15:18:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/DATDIF-Function-Format-input-help/m-p/419587#M103186</guid>
      <dc:creator>DeclanBall</dc:creator>
      <dc:date>2017-12-08T15:18:23Z</dc:date>
    </item>
    <item>
      <title>Re: DATDIF Function - Format input help</title>
      <link>https://communities.sas.com/t5/SAS-Programming/DATDIF-Function-Format-input-help/m-p/419595#M103187</link>
      <description>&lt;P&gt;Do something like this.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can use the DATDIF function, but I prefer the INTCK function because it is much more flexible.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I included examples of both, yielding the same result &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input date1:yymmdd6. date2:yymmdd6.;
datalines;
170102 170320
;

data want;
	set have;
	format date1 date2 date9.;
	days_datdif = datdif(date1, date2, 'act/act');
	days_intck = intck('day', date1, date2);
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 08 Dec 2017 15:24:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/DATDIF-Function-Format-input-help/m-p/419595#M103187</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2017-12-08T15:24:52Z</dc:date>
    </item>
    <item>
      <title>Re: DATDIF Function - Format input help</title>
      <link>https://communities.sas.com/t5/SAS-Programming/DATDIF-Function-Format-input-help/m-p/419598#M103188</link>
      <description>&lt;P&gt;Is your value a numeric with the value of&amp;nbsp;170102. Or is it a date value of 20821 displayed with the SAS display format of yymmdd6.?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;SAS data values which are required for any of the date functions to work are days offset from 1 Jan 1960. So if you date 170102 is supposed to be 2 Jan 2017 then the numeric value would have to be 20821.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;BTW when working with SAS FORMAT has a very specific interpretation of a display, not the actual values.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If your value is numeric and ALL of them have 6 digits you can create a SAS date value for use with the date functions and date FORMATS with&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;newdatevar = input(put(datevar,6.),yymmdd6.);&lt;/P&gt;
&lt;P&gt;in a data step where datevar is your existing date variable and newdatevar is the SAS date valued variable.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The appearance of the newdatevar would be set with a format, either at use or assign a default format at creation with a line like:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;format newdatevar date9. ; &amp;lt;= displays date as 02JAN2017&lt;/P&gt;
&lt;P&gt;format newdatevar mmddyy10. ; &amp;lt;= displays date as 01/02/2017 or any of many date format choices.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The SAS formats are very flexible in that you can use a different format in different procedures to create different groupings of your date variables without creating new variables.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;A second hint: Using 2 digit years in this day an age is getting to be a poor practice. It is not obvious that 170102 is in 2017 or 1917.&lt;/P&gt;
&lt;P&gt;And when the date in question is 010203 which is month, day and year is a complete guess.&lt;/P&gt;</description>
      <pubDate>Fri, 08 Dec 2017 15:34:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/DATDIF-Function-Format-input-help/m-p/419598#M103188</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2017-12-08T15:34:00Z</dc:date>
    </item>
    <item>
      <title>Re: DATDIF Function - Format input help</title>
      <link>https://communities.sas.com/t5/SAS-Programming/DATDIF-Function-Format-input-help/m-p/419605#M103191</link>
      <description>&lt;P&gt;Days between = end date - start date.&lt;/P&gt;
&lt;P&gt;You don't need datdif or intck for this.&lt;/P&gt;</description>
      <pubDate>Fri, 08 Dec 2017 15:44:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/DATDIF-Function-Format-input-help/m-p/419605#M103191</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2017-12-08T15:44:40Z</dc:date>
    </item>
    <item>
      <title>Re: DATDIF Function - Format input help</title>
      <link>https://communities.sas.com/t5/SAS-Programming/DATDIF-Function-Format-input-help/m-p/419611#M103193</link>
      <description>Yes value was numeric.&lt;BR /&gt;&lt;BR /&gt;I've used your suggestions of converting the values using:&lt;BR /&gt;newdatevar = input(put(datevar,6.),yymmdd6.);&lt;BR /&gt;&lt;BR /&gt;and then I have simply taken the difference between the two.&lt;BR /&gt;&lt;BR /&gt;Many thanks!</description>
      <pubDate>Fri, 08 Dec 2017 15:56:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/DATDIF-Function-Format-input-help/m-p/419611#M103193</guid>
      <dc:creator>DeclanBall</dc:creator>
      <dc:date>2017-12-08T15:56:04Z</dc:date>
    </item>
  </channel>
</rss>

