<?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 Calculate age in months from yyyymm dates in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Calculate-age-in-months-from-yyyymm-dates/m-p/372113#M88919</link>
    <description>&lt;P&gt;I have two date variables both in yyyymm format. It looks like 201601 and character. I'd like to calculate age in months. Below code didn't work, of course.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;age=(discharge_date-patient_birth_date)/30;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Thanks for help.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 30 Jun 2017 11:58:19 GMT</pubDate>
    <dc:creator>Cruise</dc:creator>
    <dc:date>2017-06-30T11:58:19Z</dc:date>
    <item>
      <title>Calculate age in months from yyyymm dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Calculate-age-in-months-from-yyyymm-dates/m-p/372113#M88919</link>
      <description>&lt;P&gt;I have two date variables both in yyyymm format. It looks like 201601 and character. I'd like to calculate age in months. Below code didn't work, of course.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;age=(discharge_date-patient_birth_date)/30;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Thanks for help.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 30 Jun 2017 11:58:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Calculate-age-in-months-from-yyyymm-dates/m-p/372113#M88919</guid>
      <dc:creator>Cruise</dc:creator>
      <dc:date>2017-06-30T11:58:19Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate age in months from yyyymm dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Calculate-age-in-months-from-yyyymm-dates/m-p/372125#M88923</link>
      <description>&lt;P&gt;First you need to expand the incomplete dates to real dates, then you can convert those to SAS date values, with which you can use the SAS date functions:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;age = intck('month',input(patient_birth_date !! '01',yymmdd8.),input(discharge_date !! '01',yymmdd8.));&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Edit: changed order of variables to get a positive month count. &lt;/P&gt;</description>
      <pubDate>Fri, 30 Jun 2017 12:20:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Calculate-age-in-months-from-yyyymm-dates/m-p/372125#M88923</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2017-06-30T12:20:31Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate age in months from yyyymm dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Calculate-age-in-months-from-yyyymm-dates/m-p/372126#M88924</link>
      <description>&lt;P&gt;Use INTCK function&lt;/P&gt;</description>
      <pubDate>Fri, 30 Jun 2017 12:16:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Calculate-age-in-months-from-yyyymm-dates/m-p/372126#M88924</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2017-06-30T12:16:58Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate age in months from yyyymm dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Calculate-age-in-months-from-yyyymm-dates/m-p/372127#M88925</link>
      <description>It gave me minus values, such -23, -12 et.c</description>
      <pubDate>Fri, 30 Jun 2017 12:19:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Calculate-age-in-months-from-yyyymm-dates/m-p/372127#M88925</guid>
      <dc:creator>Cruise</dc:creator>
      <dc:date>2017-06-30T12:19:42Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate age in months from yyyymm dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Calculate-age-in-months-from-yyyymm-dates/m-p/372128#M88926</link>
      <description>Got it. worked out. Switched the position of two dates. Thanks</description>
      <pubDate>Fri, 30 Jun 2017 12:20:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Calculate-age-in-months-from-yyyymm-dates/m-p/372128#M88926</guid>
      <dc:creator>Cruise</dc:creator>
      <dc:date>2017-06-30T12:20:52Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate age in months from yyyymm dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Calculate-age-in-months-from-yyyymm-dates/m-p/372132#M88927</link>
      <description>&lt;P&gt;Be very careful about using the INTCK function. &amp;nbsp;You need to understand what it counts, which barely resembles your original formula (difference in days / 30).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;INTCK measure the number of boundaries crossed. &amp;nbsp;When dealing with months, it measures the number of "1st of the month" dates within the interval. &amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;January 2, 2017 to January 30, 2017 ==&amp;gt; INTCK returns 0, since there are no "1st of the month" dates within the interval.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;January 31, 2017 to February 2, 2017 ==&amp;gt; INTCK returns 1, since there is one "1st of the month" date within the interval&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Along the way, you did figure out how to convert your character values to numeric dates, but you might want to change the formula and get rid of INTCK. &amp;nbsp;At least you should be aware of what you are getting so you can make that choice.&lt;/P&gt;</description>
      <pubDate>Fri, 30 Jun 2017 12:40:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Calculate-age-in-months-from-yyyymm-dates/m-p/372132#M88927</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2017-06-30T12:40:19Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate age in months from yyyymm dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Calculate-age-in-months-from-yyyymm-dates/m-p/372193#M88947</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/4954"&gt;@Astounding&lt;/a&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks.&lt;/P&gt;&lt;P&gt;I'm dealing with newborn data where age is often less than a month. Ideally would calculate it in days but i have no access to confidential data with complete yyyymmdd yet.&lt;/P&gt;&lt;P&gt;Curious to se ethe difference with intck vs wihout intck. Simply removing intck didn't work out. Could you edit in below code for the version without intck?&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;age = ('month',(input(patient_birth_date !! '01',yymmdd8.)),input( discharge_date !! '01',yymmdd8.));&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 30 Jun 2017 14:39:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Calculate-age-in-months-from-yyyymm-dates/m-p/372193#M88947</guid>
      <dc:creator>Cruise</dc:creator>
      <dc:date>2017-06-30T14:39:41Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate age in months from yyyymm dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Calculate-age-in-months-from-yyyymm-dates/m-p/372200#M88951</link>
      <description>&lt;P&gt;Subtracting with dates will give the number of days difference. If you are imputing a day of the month as shown you might consider using 15 instead of 01 to minimize the mean bias potential. That is a recommendation from CDC on using there standard growth curve data when calculating age from year/month data.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="SAS Monospace" size="2"&gt;days = (input( discharge_date !! &lt;/FONT&gt;&lt;FONT color="#800080" face="SAS Monospace" size="2"&gt;'151'&lt;/FONT&gt;&lt;FONT face="SAS Monospace" size="2"&gt;,&lt;/FONT&gt;&lt;FONT color="#804040" face="SAS Monospace" size="2"&gt;yymmdd8.&lt;/FONT&gt;&lt;FONT face="SAS Monospace" size="2"&gt;)) - (input(patient_birth_date !! &lt;/FONT&gt;&lt;FONT color="#800080" face="SAS Monospace" size="2"&gt;'15'&lt;/FONT&gt;&lt;FONT face="SAS Monospace" size="2"&gt;,&lt;/FONT&gt;&lt;FONT color="#804040" face="SAS Monospace" size="2"&gt;yymmdd8.&lt;/FONT&gt;&lt;FONT face="SAS Monospace" size="2"&gt;));&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 30 Jun 2017 14:51:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Calculate-age-in-months-from-yyyymm-dates/m-p/372200#M88951</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2017-06-30T14:51:39Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate age in months from yyyymm dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Calculate-age-in-months-from-yyyymm-dates/m-p/372258#M88986</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13884"&gt;@ballardw&lt;/a&gt;&lt;/P&gt;&lt;P&gt;I appreciate it. Directly relevant to my context as well. One more question, may I?&amp;nbsp;&lt;/P&gt;&lt;P&gt;Do you know how to calculate age at current date? below didn't work out.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;age_now = (( today,yymmdd8.)) - (input(patient_birth_date !! '15',yymmdd8.));&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 30 Jun 2017 17:26:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Calculate-age-in-months-from-yyyymm-dates/m-p/372258#M88986</guid>
      <dc:creator>Cruise</dc:creator>
      <dc:date>2017-06-30T17:26:39Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate age in months from yyyymm dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Calculate-age-in-months-from-yyyymm-dates/m-p/372262#M88987</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;@SUNY_Maggie wrote:&lt;BR /&gt;
&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13884"&gt;@ballardw&lt;/a&gt;&lt;/P&gt;
&lt;P&gt;I appreciate it. Directly relevant to my context as well. One more question, may I?&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Do you know how to calculate age at current date? below didn't work out.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;age_now = (( today,yymmdd8.)) - (input(patient_birth_date !! '15',yymmdd8.));&lt;/CODE&gt;&lt;/PRE&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Instead of (( today,yymmdd8.)) which tells sas to do something with a variable named Today you want the function&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;today() instead of (( today,yymmdd8.))&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You may want to investigate the SAS online help for Date functions for more goodies involved with tearing dates apart(to get day of the month or week, month of the year, the year)&amp;nbsp;or building from other variables (build a date from variables containing numeric month, day of month, and year).&lt;/P&gt;</description>
      <pubDate>Fri, 30 Jun 2017 17:34:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Calculate-age-in-months-from-yyyymm-dates/m-p/372262#M88987</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2017-06-30T17:34:25Z</dc:date>
    </item>
  </channel>
</rss>

