<?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 calculate age from birthdate using SAS VA in SAS Visual Analytics</title>
    <link>https://communities.sas.com/t5/SAS-Visual-Analytics/How-to-calculate-age-from-birthdate-using-SAS-VA/m-p/273852#M4431</link>
    <description>&lt;P&gt;Here is a more precise calculation for age as at today:&lt;/P&gt;
&lt;P&gt;IF ( (&lt;/P&gt;
&lt;P&gt;&amp;nbsp; IF ( ( ( Year(DatePart(Now())) Mod 4 ) = 0 ) AND ( DayOfYear(DatePart(Now())) &amp;gt; 59 ) )&lt;/P&gt;
&lt;P&gt;&amp;nbsp; RETURN ( DayOfYear(DatePart(Now())) - 1 )&lt;/P&gt;
&lt;P&gt;&amp;nbsp; ELSE DayOfYear(DatePart(Now())) ) &amp;lt; (&lt;/P&gt;
&lt;P&gt;&amp;nbsp; IF ( ( ( Year('Birth Date'n) Mod 4 ) = 0 ) AND ( DayOfYear('Birth Date'n) &amp;gt; 59 ) )&lt;/P&gt;
&lt;P&gt;&amp;nbsp; RETURN ( DayOfYear('Birth Date'n) - 1 )&lt;/P&gt;
&lt;P&gt;&amp;nbsp; ELSE DayOfYear('Birth Date'n) ) )&lt;/P&gt;
&lt;P&gt;RETURN ( ( Year(DatePart(Now())) - Year('Birth Date'n) ) - 1 )&lt;/P&gt;
&lt;P&gt;ELSE ( Year(DatePart(Now())) - Year('Birth Date'n) )&lt;/P&gt;
&lt;P&gt;&lt;IMG src="https://communities.sas.com/t5/image/serverpage/image-id/3384i59E74E3D29CC83A4/image-size/original?v=v2&amp;amp;px=-1" border="0" alt="Age as at today.PNG" title="Age as at today.PNG" /&gt;&lt;/P&gt;
&lt;P&gt;This considers the leap years, where 29&lt;SUP&gt;th&lt;/SUP&gt; February is the 60&lt;SUP&gt;th&lt;/SUP&gt; day of the leap year. Also replace DatePart(Now()) with a &amp;nbsp;date variable will give you the difference in year between two dates.&lt;/P&gt;</description>
    <pubDate>Mon, 30 May 2016 05:34:52 GMT</pubDate>
    <dc:creator>Expengu</dc:creator>
    <dc:date>2016-05-30T05:34:52Z</dc:date>
    <item>
      <title>How to calculate age from birthdate using SAS VA</title>
      <link>https://communities.sas.com/t5/SAS-Visual-Analytics/How-to-calculate-age-from-birthdate-using-SAS-VA/m-p/232592#M2718</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm a total noob in SAS VA. Currently using SAS VA 7.2.&lt;/P&gt;&lt;P&gt;Kindly advise how to calculate age from birthdate using SAS VA.&lt;/P&gt;&lt;P&gt;This should be simple, just substraction between today and birthdate.&lt;/P&gt;&lt;P&gt;I looked at the Operators in New Calculated Item, but nothing worked.&lt;/P&gt;&lt;P&gt;I have searched/googled this topic but what the solutions were using SAS programming or EG, but not applicable in SAS VA.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you.&lt;/P&gt;</description>
      <pubDate>Sat, 31 Oct 2015 21:50:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Visual-Analytics/How-to-calculate-age-from-birthdate-using-SAS-VA/m-p/232592#M2718</guid>
      <dc:creator>ksulistyo</dc:creator>
      <dc:date>2015-10-31T21:50:00Z</dc:date>
    </item>
    <item>
      <title>Re: How to calculate age from birthdate using SAS VA</title>
      <link>https://communities.sas.com/t5/SAS-Visual-Analytics/How-to-calculate-age-from-birthdate-using-SAS-VA/m-p/232608#M2719</link>
      <description>&lt;P&gt;I'm not sure of SAS VA is different from SAS Base, but ran across this.... might help you...&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;age = INT(YRDIF(birth-date, ending-date,'ACTUAL'));&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://support.sas.com/publishing/authors/extras/61860_update.pdf" target="_blank"&gt;https://support.sas.com/publishing/authors/extras/61860_update.pdf&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Sun, 01 Nov 2015 02:18:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Visual-Analytics/How-to-calculate-age-from-birthdate-using-SAS-VA/m-p/232608#M2719</guid>
      <dc:creator>kannand</dc:creator>
      <dc:date>2015-11-01T02:18:21Z</dc:date>
    </item>
    <item>
      <title>Re: How to calculate age from birthdate using SAS VA</title>
      <link>https://communities.sas.com/t5/SAS-Visual-Analytics/How-to-calculate-age-from-birthdate-using-SAS-VA/m-p/232613#M2720</link>
      <description>&lt;P&gt;The syntax is&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;age = YRDIF(birthDate, refDate, "AGE");&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;where &lt;EM&gt;refDate&lt;/EM&gt; can be &lt;STRONG&gt;Today()&lt;/STRONG&gt; if that is what you want.&lt;/P&gt;</description>
      <pubDate>Sun, 01 Nov 2015 03:07:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Visual-Analytics/How-to-calculate-age-from-birthdate-using-SAS-VA/m-p/232613#M2720</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2015-11-01T03:07:22Z</dc:date>
    </item>
    <item>
      <title>Re: How to calculate age from birthdate using SAS VA</title>
      <link>https://communities.sas.com/t5/SAS-Visual-Analytics/How-to-calculate-age-from-birthdate-using-SAS-VA/m-p/232615#M2721</link>
      <description>&lt;P&gt;Welcome to the SAS Visual Analytics community.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;As you may have discovered dates in SAS Visual Analytics are not treated the same way as Base SAS. Also the very useful Base SAS date functions such as intck and yrdif are not available.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;A date in SAS Visual Analytics is treated as a category data item and not as the traditional SAS date type in the interface. The underlying storage is a SAS date number so you can use the Year function and DatePart function (in case your date is datetime) and you use the TreatAs function to treat the data item as a number if you want to calculate the days. Have a read through the post &lt;A href="https://communities.sas.com/t5/SAS-Visual-Analytics/Finding-No-of-Days-between-two-dates-in-SAS-VA/m-p/153702/highlight/true#M617" target="_blank"&gt;https://communities.sas.com/t5/SAS-Visual-Analytics/Finding-No-of-Days-between-two-dates-in-SAS-VA/m-p/153702/highlight/true#M617&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In future, please search first the community before posting a question as you may find your question has been answered already. &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;P&gt;Kind Regards,&lt;/P&gt;
&lt;P&gt;Michelle&lt;/P&gt;</description>
      <pubDate>Sun, 01 Nov 2015 03:19:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Visual-Analytics/How-to-calculate-age-from-birthdate-using-SAS-VA/m-p/232615#M2721</guid>
      <dc:creator>MichelleHomes</dc:creator>
      <dc:date>2015-11-01T03:19:14Z</dc:date>
    </item>
    <item>
      <title>Re: How to calculate age from birthdate using SAS VA</title>
      <link>https://communities.sas.com/t5/SAS-Visual-Analytics/How-to-calculate-age-from-birthdate-using-SAS-VA/m-p/232623#M2722</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you for all your responses.&lt;/P&gt;
&lt;P&gt;Unfortunately SAS VA doesn't support YRDIF.&lt;/P&gt;
&lt;P&gt;I followed the link from Michelle with some modification and it worked &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;Here is what I do:&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; ( TreatAs(_Number_, Now()) - TreatAs(_Number_, 'Birthdate'n) ) / ( 365 * 24 * 60 * 60 )&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Regards,&lt;/P&gt;
&lt;P&gt;Karina&lt;/P&gt;&lt;BR /&gt;&lt;IMG src="https://communities.sas.com/t5/image/serverpage/image-id/12045iC0D1C5C552BB6B8B/image-size/large?v=1.0&amp;amp;px=600" border="0" alt="Calculating Age From Birthdate.png" title="Calculating Age From Birthdate.png" /&gt;</description>
      <pubDate>Sun, 01 Nov 2015 06:49:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Visual-Analytics/How-to-calculate-age-from-birthdate-using-SAS-VA/m-p/232623#M2722</guid>
      <dc:creator>ksulistyo</dc:creator>
      <dc:date>2015-11-01T06:49:28Z</dc:date>
    </item>
    <item>
      <title>Re: How to calculate age from birthdate using SAS VA</title>
      <link>https://communities.sas.com/t5/SAS-Visual-Analytics/How-to-calculate-age-from-birthdate-using-SAS-VA/m-p/273852#M4431</link>
      <description>&lt;P&gt;Here is a more precise calculation for age as at today:&lt;/P&gt;
&lt;P&gt;IF ( (&lt;/P&gt;
&lt;P&gt;&amp;nbsp; IF ( ( ( Year(DatePart(Now())) Mod 4 ) = 0 ) AND ( DayOfYear(DatePart(Now())) &amp;gt; 59 ) )&lt;/P&gt;
&lt;P&gt;&amp;nbsp; RETURN ( DayOfYear(DatePart(Now())) - 1 )&lt;/P&gt;
&lt;P&gt;&amp;nbsp; ELSE DayOfYear(DatePart(Now())) ) &amp;lt; (&lt;/P&gt;
&lt;P&gt;&amp;nbsp; IF ( ( ( Year('Birth Date'n) Mod 4 ) = 0 ) AND ( DayOfYear('Birth Date'n) &amp;gt; 59 ) )&lt;/P&gt;
&lt;P&gt;&amp;nbsp; RETURN ( DayOfYear('Birth Date'n) - 1 )&lt;/P&gt;
&lt;P&gt;&amp;nbsp; ELSE DayOfYear('Birth Date'n) ) )&lt;/P&gt;
&lt;P&gt;RETURN ( ( Year(DatePart(Now())) - Year('Birth Date'n) ) - 1 )&lt;/P&gt;
&lt;P&gt;ELSE ( Year(DatePart(Now())) - Year('Birth Date'n) )&lt;/P&gt;
&lt;P&gt;&lt;IMG src="https://communities.sas.com/t5/image/serverpage/image-id/3384i59E74E3D29CC83A4/image-size/original?v=v2&amp;amp;px=-1" border="0" alt="Age as at today.PNG" title="Age as at today.PNG" /&gt;&lt;/P&gt;
&lt;P&gt;This considers the leap years, where 29&lt;SUP&gt;th&lt;/SUP&gt; February is the 60&lt;SUP&gt;th&lt;/SUP&gt; day of the leap year. Also replace DatePart(Now()) with a &amp;nbsp;date variable will give you the difference in year between two dates.&lt;/P&gt;</description>
      <pubDate>Mon, 30 May 2016 05:34:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Visual-Analytics/How-to-calculate-age-from-birthdate-using-SAS-VA/m-p/273852#M4431</guid>
      <dc:creator>Expengu</dc:creator>
      <dc:date>2016-05-30T05:34:52Z</dc:date>
    </item>
  </channel>
</rss>

