<?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: Mean age based on birth date in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Mean-age-based-on-birth-date/m-p/491417#M128861</link>
    <description>&lt;P&gt;To calculate a mean age, you first need to calculate an age for&amp;nbsp;each individual in your data set&amp;nbsp;and then take the average of that variable in PROC MEANS.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here's how to calculate someone's age.&lt;/P&gt;
&lt;P&gt;&lt;A href="https://blogs.sas.com/content/sasdummy/2011/07/12/computing-age-in-sas-9-3/" target="_blank"&gt;https://blogs.sas.com/content/sasdummy/2011/07/12/computing-age-in-sas-9-3/&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And then you can use PROC MEANS as shown to do the average of the age variable, which you've already shown.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/228622"&gt;@jbrau123&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hello&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am struggling a bit making a table with&amp;nbsp;average dates / average age. I can make tables with date formats, but I am not able to calculate average date / average age. If I try, I just get the unformatted output, which is "2819.92".&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc Means data=My.data;&lt;/P&gt;
&lt;P&gt;var Date;&lt;/P&gt;
&lt;P&gt;format date9.;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I would have thought I could find other cases on this forum&amp;nbsp;with same issue, but unfortunately not, so I hope someone can help&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 30 Aug 2018 20:38:05 GMT</pubDate>
    <dc:creator>Reeza</dc:creator>
    <dc:date>2018-08-30T20:38:05Z</dc:date>
    <item>
      <title>Mean age based on birth date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Mean-age-based-on-birth-date/m-p/491230#M128770</link>
      <description>&lt;P&gt;Hello&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am struggling a bit making a table with&amp;nbsp;average dates / average age. I can make tables with date formats, but I am not able to calculate average date / average age. If I try, I just get the unformatted output, which is "2819.92".&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;proc Means data=My.data;&lt;/P&gt;&lt;P&gt;var Date;&lt;/P&gt;&lt;P&gt;format date9.;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I would have thought I could find other cases on this forum&amp;nbsp;with same issue, but unfortunately not, so I hope someone can help&lt;/P&gt;</description>
      <pubDate>Thu, 30 Aug 2018 13:34:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Mean-age-based-on-birth-date/m-p/491230#M128770</guid>
      <dc:creator>jbrau123</dc:creator>
      <dc:date>2018-08-30T13:34:26Z</dc:date>
    </item>
    <item>
      <title>Re: Mean age based on birth date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Mean-age-based-on-birth-date/m-p/491258#M128782</link>
      <description>&lt;P&gt;Please provide some test data/required output.&amp;nbsp; Mean of a date doesn't make sense,&amp;nbsp;&lt;SPAN&gt;2819.92 tells you that the mean does not end up as an integer.&amp;nbsp; Numeric dates are number of days since the cuttoff, they can only be integer.&amp;nbsp; Perhaps you want median rather than mean.&amp;nbsp; Mean age should be alright though.&amp;nbsp; Need some demonstration to show what you are doing / want.&lt;/SPAN&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 30 Aug 2018 14:25:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Mean-age-based-on-birth-date/m-p/491258#M128782</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2018-08-30T14:25:41Z</dc:date>
    </item>
    <item>
      <title>Re: Mean age based on birth date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Mean-age-based-on-birth-date/m-p/491266#M128787</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/228622"&gt;@jbrau123&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hello&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am struggling a bit making a table with&amp;nbsp;average dates / average age. I can make tables with date formats, but I am not able to calculate average date / average age. If I try, I just get the unformatted output, which is "2819.92".&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc Means data=My.data;&lt;/P&gt;
&lt;P&gt;var Date;&lt;/P&gt;
&lt;P&gt;format date9.;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I would have thought I could find other cases on this forum&amp;nbsp;with same issue, but unfortunately not, so I hope someone can help&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Proc means does that: statistics don't inherit a format from the variable used.&lt;/P&gt;
&lt;P&gt;To see a date formatted value for the mean then 1) direct the output of proc means to a data set and 2) apply the format when displaying or using that statistic. The date formats will only display the integer portion of the numeric value as a date.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Caveat: if you later test the mean to a value such as&amp;nbsp;: if data_mean = '10AUG2018'd you likely won't get matches as the decimal portion is in the mean and seldom matches an exact date. I use a literal here but the same warning applies if comparing to any date value.&lt;/P&gt;</description>
      <pubDate>Thu, 30 Aug 2018 14:43:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Mean-age-based-on-birth-date/m-p/491266#M128787</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2018-08-30T14:43:15Z</dc:date>
    </item>
    <item>
      <title>Re: Mean age based on birth date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Mean-age-based-on-birth-date/m-p/491299#M128815</link>
      <description>&lt;P&gt;I don't quite understand what you are suggesting. Could you provide coding?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Kind regards,&lt;/P&gt;&lt;P&gt;Jacob&lt;/P&gt;</description>
      <pubDate>Thu, 30 Aug 2018 15:28:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Mean-age-based-on-birth-date/m-p/491299#M128815</guid>
      <dc:creator>jbrau123</dc:creator>
      <dc:date>2018-08-30T15:28:38Z</dc:date>
    </item>
    <item>
      <title>Re: Mean age based on birth date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Mean-age-based-on-birth-date/m-p/491303#M128819</link>
      <description>&lt;P&gt;Instead of letting PROC MEANS print the output, create an output data set.&amp;nbsp; Then you can choose the formatting:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc means data=have noprint;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;var date;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;output out=want (keep=mean_date) mean=mean_date;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc print data=want;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;var mean_date;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;format mean_date date9.;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;</description>
      <pubDate>Thu, 30 Aug 2018 15:35:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Mean-age-based-on-birth-date/m-p/491303#M128819</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2018-08-30T15:35:03Z</dc:date>
    </item>
    <item>
      <title>Re: Mean age based on birth date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Mean-age-based-on-birth-date/m-p/491417#M128861</link>
      <description>&lt;P&gt;To calculate a mean age, you first need to calculate an age for&amp;nbsp;each individual in your data set&amp;nbsp;and then take the average of that variable in PROC MEANS.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here's how to calculate someone's age.&lt;/P&gt;
&lt;P&gt;&lt;A href="https://blogs.sas.com/content/sasdummy/2011/07/12/computing-age-in-sas-9-3/" target="_blank"&gt;https://blogs.sas.com/content/sasdummy/2011/07/12/computing-age-in-sas-9-3/&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And then you can use PROC MEANS as shown to do the average of the age variable, which you've already shown.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/228622"&gt;@jbrau123&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hello&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am struggling a bit making a table with&amp;nbsp;average dates / average age. I can make tables with date formats, but I am not able to calculate average date / average age. If I try, I just get the unformatted output, which is "2819.92".&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc Means data=My.data;&lt;/P&gt;
&lt;P&gt;var Date;&lt;/P&gt;
&lt;P&gt;format date9.;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I would have thought I could find other cases on this forum&amp;nbsp;with same issue, but unfortunately not, so I hope someone can help&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 30 Aug 2018 20:38:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Mean-age-based-on-birth-date/m-p/491417#M128861</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-08-30T20:38:05Z</dc:date>
    </item>
  </channel>
</rss>

