<?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: Calculating date of birth backwards, using a transaction date and age. in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Calculating-date-of-birth-backwards-using-a-transaction-date-and/m-p/507215#M136094</link>
    <description>&lt;P&gt;&lt;SPAN&gt;This particular data set has already been parsed for duplicate observations and there is only one transaction date for each individual. However, I appreciate the additional advice to help generalize this code to any context!&lt;/SPAN&gt;&lt;/P&gt;</description>
    <pubDate>Wed, 24 Oct 2018 15:55:52 GMT</pubDate>
    <dc:creator>atiedt</dc:creator>
    <dc:date>2018-10-24T15:55:52Z</dc:date>
    <item>
      <title>Calculating date of birth backwards, using a transaction date and age.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Calculating-date-of-birth-backwards-using-a-transaction-date-and/m-p/507165#M136061</link>
      <description>&lt;P&gt;Is it possible to calculate a date of birth, working backwards, with an Age variable and a transaction date?&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For example, this code seems to work, but I am missing leap years. There doesn't seem to be a way to do this with intnx or intck.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;DATA WANT;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;SET HAVE;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; IF AGE NE . AND TDATE NE. THEN DO;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; DOB = TDATE - (AGE*365.25);&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; FORMAT DOB DATE9;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;END;&lt;/P&gt;&lt;P&gt;RUN;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for your advice!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 24 Oct 2018 14:26:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Calculating-date-of-birth-backwards-using-a-transaction-date-and/m-p/507165#M136061</guid>
      <dc:creator>atiedt</dc:creator>
      <dc:date>2018-10-24T14:26:29Z</dc:date>
    </item>
    <item>
      <title>Re: Calculating date of birth backwards, using a transaction date and age.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Calculating-date-of-birth-backwards-using-a-transaction-date-and/m-p/507169#M136062</link>
      <description>&lt;P&gt;What do you mean by transaction data? What does it represent?&lt;/P&gt;</description>
      <pubDate>Wed, 24 Oct 2018 14:29:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Calculating-date-of-birth-backwards-using-a-transaction-date-and/m-p/507169#M136062</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2018-10-24T14:29:35Z</dc:date>
    </item>
    <item>
      <title>Re: Calculating date of birth backwards, using a transaction date and age.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Calculating-date-of-birth-backwards-using-a-transaction-date-and/m-p/507173#M136065</link>
      <description>&lt;P&gt;Intnx() DOES work:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
tdate = today();
age = 15;
dob = intnx('year',tdate,-age,'s');
format tdate dob yymmddd10.;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 24 Oct 2018 14:36:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Calculating-date-of-birth-backwards-using-a-transaction-date-and/m-p/507173#M136065</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2018-10-24T14:36:54Z</dc:date>
    </item>
    <item>
      <title>Re: Calculating date of birth backwards, using a transaction date and age.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Calculating-date-of-birth-backwards-using-a-transaction-date-and/m-p/507176#M136067</link>
      <description>&lt;P&gt;Do note, that just having Age and a Date will not give you the date of birth, only the rough year, e.g: date 12May2018, age =12, DOB=2006, its not even possible to guarentee that is the right year.&lt;/P&gt;</description>
      <pubDate>Wed, 24 Oct 2018 14:44:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Calculating-date-of-birth-backwards-using-a-transaction-date-and/m-p/507176#M136067</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2018-10-24T14:44:45Z</dc:date>
    </item>
    <item>
      <title>Re: Calculating date of birth backwards, using a transaction date and age.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Calculating-date-of-birth-backwards-using-a-transaction-date-and/m-p/507196#M136078</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/86439"&gt;@atiedt&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Is it possible to calculate a date of birth, working backwards, with an Age variable and a transaction date?&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For example, this code seems to work, but I am missing leap years. There doesn't seem to be a way to do this with intnx or intck.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;DATA WANT;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;SET HAVE;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; IF AGE NE . AND TDATE NE. THEN DO;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; DOB = TDATE - (AGE*365.25);&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; FORMAT DOB DATE9;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;END;&lt;/P&gt;
&lt;P&gt;RUN;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks for your advice!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Do you have multiple "transactions" for any of these people? Perhaps find the estimated DOB as you are doing then take a mean across the multiple transactions.&lt;/P&gt;
&lt;P&gt;What ever approach, if you do have multiple transactions you likely should do something to derive a single DOB per person.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Note that if either of AGE or TDATE are missing then the calculation would result in missing. Which is the same result as skipping the calculation. So might as well not bother with the IF/Then/Do/End portion at all. If your data does something on the silly side such as use a specific date such as 1/1/9999 for "missing" then you would want to exclude for those dates though. Actually I would have set those to missing before getting this far.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;CAUTION:&lt;/STRONG&gt; Using a value such as DOB = TDATE - (AGE*365.25); with an associated decimal portion, small though it may be, can introduce odd behaviors and it&amp;nbsp;may be a very good idea to round or truncate the decimal portions.&lt;/P&gt;
&lt;P&gt;An example is comparison to fixed values:&lt;/P&gt;
&lt;PRE&gt;data example;
   x= '01JAN2018'd + .01;
   if x le '01JAN2018'd then put 'Date in wanted range &amp;lt;= 01JAN2018 '  x= date9.;
   else put 'Date not in wanted range &amp;lt;= 01JAN2018 ' x= date9.;
run;&lt;/PRE&gt;
&lt;P&gt;would result in&lt;/P&gt;
&lt;PRE&gt;Date not in wanted range &amp;lt;= 01JAN2018 x=01JAN2018

&lt;/PRE&gt;
&lt;P&gt;and you could spend a lot of time tracing down that the &lt;STRONG&gt;formatted&lt;/STRONG&gt; value of the date is ignoring the decimal portion of the date value in the message or other result table while&amp;nbsp; the actual value is compared using the decimal portion.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 24 Oct 2018 20:01:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Calculating-date-of-birth-backwards-using-a-transaction-date-and/m-p/507196#M136078</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2018-10-24T20:01:02Z</dc:date>
    </item>
    <item>
      <title>Re: Calculating date of birth backwards, using a transaction date and age.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Calculating-date-of-birth-backwards-using-a-transaction-date-and/m-p/507214#M136093</link>
      <description>&lt;P&gt;This particular data set has already been parsed for duplicate observations and there is only one transaction date for each individual. However, I appreciate the additional advice to help generalize this code to any context!&lt;/P&gt;</description>
      <pubDate>Wed, 24 Oct 2018 15:55:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Calculating-date-of-birth-backwards-using-a-transaction-date-and/m-p/507214#M136093</guid>
      <dc:creator>atiedt</dc:creator>
      <dc:date>2018-10-24T15:55:04Z</dc:date>
    </item>
    <item>
      <title>Re: Calculating date of birth backwards, using a transaction date and age.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Calculating-date-of-birth-backwards-using-a-transaction-date-and/m-p/507215#M136094</link>
      <description>&lt;P&gt;&lt;SPAN&gt;This particular data set has already been parsed for duplicate observations and there is only one transaction date for each individual. However, I appreciate the additional advice to help generalize this code to any context!&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 24 Oct 2018 15:55:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Calculating-date-of-birth-backwards-using-a-transaction-date-and/m-p/507215#M136094</guid>
      <dc:creator>atiedt</dc:creator>
      <dc:date>2018-10-24T15:55:52Z</dc:date>
    </item>
  </channel>
</rss>

