<?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: How to convert date to days in SAS Studio</title>
    <link>https://communities.sas.com/t5/SAS-Studio/How-to-convert-date-to-days/m-p/613506#M8516</link>
    <description>Thank you for suggestion, actually I'm trying to calculate age from two variables. While calculating age should we consider time and seconds or not</description>
    <pubDate>Mon, 23 Dec 2019 11:07:31 GMT</pubDate>
    <dc:creator>sasuser123123</dc:creator>
    <dc:date>2019-12-23T11:07:31Z</dc:date>
    <item>
      <title>How to convert date to days</title>
      <link>https://communities.sas.com/t5/SAS-Studio/How-to-convert-date-to-days/m-p/613501#M8513</link>
      <description>Hello !&lt;BR /&gt;&lt;BR /&gt;I've a variable 'date' which is numeric variable it contains date 29Dec08:10:00:00 so I need to convert into days. so how to convert this date to days . I'm wrote&lt;BR /&gt;Newdate=input(put (date,datetime18.), datetime18.),&lt;BR /&gt;But I got wrong numeric dates.. could you please solve this query..&lt;BR /&gt;&lt;BR /&gt;Thank you.!&lt;BR /&gt;Regards..</description>
      <pubDate>Mon, 23 Dec 2019 10:20:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/How-to-convert-date-to-days/m-p/613501#M8513</guid>
      <dc:creator>sasuser123123</dc:creator>
      <dc:date>2019-12-23T10:20:37Z</dc:date>
    </item>
    <item>
      <title>Re: How to convert date to days</title>
      <link>https://communities.sas.com/t5/SAS-Studio/How-to-convert-date-to-days/m-p/613502#M8514</link>
      <description>&lt;P&gt;You do not have a date, you have a datetime. Datetimes are counts of seconds, dates are counts of days. To extract the date from a datetime, use the datepart() function.&lt;/P&gt;
&lt;P&gt;Your double function call keeps the value as it is, only cutting off any fractions of seconds, which could be achieved easier with round().&lt;/P&gt;</description>
      <pubDate>Mon, 23 Dec 2019 10:28:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/How-to-convert-date-to-days/m-p/613502#M8514</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2019-12-23T10:28:09Z</dc:date>
    </item>
    <item>
      <title>Re: How to convert date to days</title>
      <link>https://communities.sas.com/t5/SAS-Studio/How-to-convert-date-to-days/m-p/613503#M8515</link>
      <description>&lt;P&gt;I don't know what you mean by converting a date into days,&lt;/P&gt;
&lt;P&gt;but may be you mean:&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; date = &lt;STRONG&gt;datepart&lt;/STRONG&gt;(datetime_variable);&lt;/P&gt;</description>
      <pubDate>Mon, 23 Dec 2019 10:28:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/How-to-convert-date-to-days/m-p/613503#M8515</guid>
      <dc:creator>Shmuel</dc:creator>
      <dc:date>2019-12-23T10:28:16Z</dc:date>
    </item>
    <item>
      <title>Re: How to convert date to days</title>
      <link>https://communities.sas.com/t5/SAS-Studio/How-to-convert-date-to-days/m-p/613506#M8516</link>
      <description>Thank you for suggestion, actually I'm trying to calculate age from two variables. While calculating age should we consider time and seconds or not</description>
      <pubDate>Mon, 23 Dec 2019 11:07:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/How-to-convert-date-to-days/m-p/613506#M8516</guid>
      <dc:creator>sasuser123123</dc:creator>
      <dc:date>2019-12-23T11:07:31Z</dc:date>
    </item>
    <item>
      <title>Re: How to convert date to days</title>
      <link>https://communities.sas.com/t5/SAS-Studio/How-to-convert-date-to-days/m-p/613510#M8517</link>
      <description>&lt;P&gt;having to variables you can calculate age by subtracting years:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; age = intck('year', datetime2, datetime1);&lt;/P&gt;
&lt;P&gt;or&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;age = intck('year', date2, date1);&lt;/P&gt;</description>
      <pubDate>Mon, 23 Dec 2019 11:41:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/How-to-convert-date-to-days/m-p/613510#M8517</guid>
      <dc:creator>Shmuel</dc:creator>
      <dc:date>2019-12-23T11:41:14Z</dc:date>
    </item>
    <item>
      <title>Re: How to convert date to days</title>
      <link>https://communities.sas.com/t5/SAS-Studio/How-to-convert-date-to-days/m-p/613525#M8518</link>
      <description>&lt;P&gt;You have to use "dtyear" as the interval.&lt;/P&gt;</description>
      <pubDate>Mon, 23 Dec 2019 13:09:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/How-to-convert-date-to-days/m-p/613525#M8518</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2019-12-23T13:09:06Z</dc:date>
    </item>
    <item>
      <title>Re: How to convert date to days</title>
      <link>https://communities.sas.com/t5/SAS-Studio/How-to-convert-date-to-days/m-p/613588#M8519</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/282134"&gt;@sasuser123123&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;Thank you for suggestion, actually I'm trying to calculate age from two variables. While calculating age should we consider time and seconds or not&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;That would be YOUR requirement to know.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Hours seldom become a consideration unless dealing with newborn babies though.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 23 Dec 2019 17:43:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/How-to-convert-date-to-days/m-p/613588#M8519</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2019-12-23T17:43:23Z</dc:date>
    </item>
    <item>
      <title>Re: How to convert date to days</title>
      <link>https://communities.sas.com/t5/SAS-Studio/How-to-convert-date-to-days/m-p/613624#M8522</link>
      <description>&lt;P&gt;The code&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;SPAN&gt;age = intck('year', date2, date1);&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;will not always produce the result you might expect, because what it counts is the number of occurences of January 1 between the two dates:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt; 69         data _null_;
 70             years = intck('year', '31dec2019'd, '01jan2020'd);
 71             put years=;
 72         run;
 
 years=1
&lt;/PRE&gt;
&lt;P&gt;Use of the CONTINUOUS option might produce the result you want:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;data _null_;
    years = intck('year', '31dec2019'd, '01jan2020'd, 'continuous');
    put years=;
run;&lt;/PRE&gt;
&lt;P&gt;The traditional method of calculating age in SAS, attributed to Billy Kreuter, is&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;age =  floor(( intck( 'month', dob, death) - ( day(death) &amp;lt; day(dob)))/ 12); &lt;/PRE&gt;
&lt;P&gt;&amp;lt;&lt;A href="https://www.lexjansen.com/pharmasug/2011/CC/PharmaSUG-2011-CC20.pdf" target="_blank"&gt;https://www.lexjansen.com/pharmasug/2011/CC/PharmaSUG-2011-CC20.pdf&lt;/A&gt;&amp;gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;There's a lazy method that just takes the difference in days and divides by 365.25.&amp;nbsp; Please don't use that method.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 23 Dec 2019 20:30:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/How-to-convert-date-to-days/m-p/613624#M8522</guid>
      <dc:creator>JackHamilton</dc:creator>
      <dc:date>2019-12-23T20:30:07Z</dc:date>
    </item>
    <item>
      <title>Re: How to convert date to days</title>
      <link>https://communities.sas.com/t5/SAS-Studio/How-to-convert-date-to-days/m-p/613632#M8523</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/11562"&gt;@Kurt_Bremser&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;You have to use "dtyear" as the interval.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Or DTDAY, DTMONTH , DTWEEK&amp;nbsp; (see a pattern here?).&lt;/P&gt;</description>
      <pubDate>Mon, 23 Dec 2019 21:23:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/How-to-convert-date-to-days/m-p/613632#M8523</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2019-12-23T21:23:11Z</dc:date>
    </item>
  </channel>
</rss>

