<?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: Aging a Given Population in SAS by Month in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Aging-a-Given-Population-in-SAS-by-Month/m-p/440227#M282515</link>
    <description>&lt;P&gt;Please post what you have so far.&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/195689"&gt;@VGutz&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;I'm looking for a way top age a given population in SAS based on current age. The population should be aged on a monthly basis, based on the month's age distribution.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;My current dataset includes the most recent completed month of&amp;nbsp;population percentages&amp;nbsp;by age and gender. Perc_0 is the current percentage of total population by age/gender. I would like to age the population based on these given formulas:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;i = current age&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Youngest age group: Next month's percentage =&amp;nbsp;(i)th&amp;nbsp;group percentage * (11/12)&lt;/P&gt;
&lt;P&gt;All other age groups: Next month's percentage = (i)th group percentage * (11/12) + (i-1)th group percentage * (1/12)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I've attached an&amp;nbsp;excel sheet displaying the current data set (highlighted in grey) and an example of a 10 month projection.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I've tried using arrays to loop through the data, but I can't figure out how to build it off of each new month of projected data; because I have to project out 24 month's worth of data, I don't want to have 24 steps copied out if I can just put it into one array or do loop.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I appreciate any help. Thank you.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 26 Feb 2018 16:05:46 GMT</pubDate>
    <dc:creator>Reeza</dc:creator>
    <dc:date>2018-02-26T16:05:46Z</dc:date>
    <item>
      <title>Aging a Given Population in SAS by Month</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Aging-a-Given-Population-in-SAS-by-Month/m-p/440200#M282514</link>
      <description>&lt;P&gt;I'm looking for a way top age a given population in SAS based on current age. The population should be aged on a monthly basis, based on the month's age distribution.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My current dataset includes the most recent completed month of&amp;nbsp;population percentages&amp;nbsp;by age and gender. Perc_0 is the current percentage of total population by age/gender. I would like to age the population based on these given formulas:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;i = current age&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Youngest age group: Next month's percentage =&amp;nbsp;(i)th&amp;nbsp;group percentage * (11/12)&lt;/P&gt;&lt;P&gt;All other age groups: Next month's percentage = (i)th group percentage * (11/12) + (i-1)th group percentage * (1/12)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I've attached an&amp;nbsp;excel sheet displaying the current data set (highlighted in grey) and an example of a 10 month projection.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I've tried using arrays to loop through the data, but I can't figure out how to build it off of each new month of projected data; because I have to project out 24 month's worth of data, I don't want to have 24 steps copied out if I can just put it into one array or do loop.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I appreciate any help. Thank you.&lt;/P&gt;</description>
      <pubDate>Mon, 26 Feb 2018 15:17:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Aging-a-Given-Population-in-SAS-by-Month/m-p/440200#M282514</guid>
      <dc:creator>VGutz</dc:creator>
      <dc:date>2018-02-26T15:17:36Z</dc:date>
    </item>
    <item>
      <title>Re: Aging a Given Population in SAS by Month</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Aging-a-Given-Population-in-SAS-by-Month/m-p/440227#M282515</link>
      <description>&lt;P&gt;Please post what you have so far.&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/195689"&gt;@VGutz&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;I'm looking for a way top age a given population in SAS based on current age. The population should be aged on a monthly basis, based on the month's age distribution.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;My current dataset includes the most recent completed month of&amp;nbsp;population percentages&amp;nbsp;by age and gender. Perc_0 is the current percentage of total population by age/gender. I would like to age the population based on these given formulas:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;i = current age&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Youngest age group: Next month's percentage =&amp;nbsp;(i)th&amp;nbsp;group percentage * (11/12)&lt;/P&gt;
&lt;P&gt;All other age groups: Next month's percentage = (i)th group percentage * (11/12) + (i-1)th group percentage * (1/12)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I've attached an&amp;nbsp;excel sheet displaying the current data set (highlighted in grey) and an example of a 10 month projection.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I've tried using arrays to loop through the data, but I can't figure out how to build it off of each new month of projected data; because I have to project out 24 month's worth of data, I don't want to have 24 steps copied out if I can just put it into one array or do loop.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I appreciate any help. Thank you.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 26 Feb 2018 16:05:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Aging-a-Given-Population-in-SAS-by-Month/m-p/440227#M282515</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-02-26T16:05:46Z</dc:date>
    </item>
    <item>
      <title>Re: Aging a Given Population in SAS by Month</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Aging-a-Given-Population-in-SAS-by-Month/m-p/440996#M282516</link>
      <description>&lt;P&gt;So far I have this code, but I need to figure out a way to loop in for 24 months.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;data&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; prev_month_0;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;set&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; month_0;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;format&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; prev_perc_0 &lt;/FONT&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;BEST12.&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;age = age + &lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;1&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;prev_perc_0 = perc_0;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;drop&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; perc_0;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;　&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;proc&lt;/STRONG&gt;&lt;/FONT&gt; &lt;STRONG&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;sql&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;; &lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;create&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Courier New" size="3"&gt;table&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; join_month_0 &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;as&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;select&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; coalesce(t1.year,t2.year) &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;as&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; year,&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;coalesce(t1.month,t2.month) &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;as&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; month,&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;coalesce(t1.quarter,t2.quarter) &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;as&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; quarter,&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;coalesce(t1.sex_cd,t2.sex_cd) &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;as&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; sex_cd,&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;coalesce(t1.age,t2.age) &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;as&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; age,&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;coalesce(t1.perc_0, &lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;0&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;) &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;as&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; perc_0,&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;coalesce(t2.prev_perc_0, &lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;0&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;) &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;as&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; prev_perc_0&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;from&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; month_0 &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;as&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; t1 &lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;full outer join prev_month_0 &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;as&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; t2&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;on&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; t1.year = t2.year&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;and&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; t1.month = t2.month&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;and&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; t1.age = t2.age&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;and&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; t1.sex_cd = t2.sex_cd;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;quit&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;; &lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;　&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;data&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; month_1;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;set&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; join_month_0;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;format&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; perc_1 &lt;/FONT&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;BEST12.&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;perc_1 = (&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;11&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;/&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;12&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;) * perc_0 + (&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;1&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;/&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;12&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;) * prev_perc_0;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;drop&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; prev_perc_0;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 28 Feb 2018 19:40:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Aging-a-Given-Population-in-SAS-by-Month/m-p/440996#M282516</guid>
      <dc:creator>VGutz</dc:creator>
      <dc:date>2018-02-28T19:40:09Z</dc:date>
    </item>
    <item>
      <title>Re: Aging a Given Population in SAS by Month</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Aging-a-Given-Population-in-SAS-by-Month/m-p/441119#M282517</link>
      <description>&lt;P&gt;This is a problem that benefits from a solution that uses&amp;nbsp;record order, which is not a strength of PROC SQL:&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
  year=2017; month=12;
  do sex='M','F';
    do age=20 to 29;
      input perc_0 @;
      output;
    end;
  end;
  format perc_0 percent7.1;
datalines;
.11 .13 .11 .07 .03 0 0 0 0 0
.12 .15 .13 .1  .05 0 0 0 0 0
run;

data want (drop=_:);
  set have;
  by descending sex  age;
  array prc {0:10} perc_0-perc_10;
  retain perc_1-perc_10;
  format perc_0-perc_10 percent7.1;

  do _m=1 to 10;
    if first.sex then  prc{_m}=0;
    prc{_m}=prc{_m-1}*11/12 + prc{_m}/12;
  end;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;By retaining the values of PERC_1-PERC_10 from row to row, it's easy to divide by twelve and add&amp;nbsp;11/12th of the preceding month (i.e. for PERC_2 add 11/12th of PERC_1).&amp;nbsp; Of course when starting a new sex, first reset PERC_1-PERC_10 to zero.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;By the way, why do your have PERC_0 through PERC_10,&amp;nbsp; and not through PERC_11?&lt;/P&gt;</description>
      <pubDate>Thu, 01 Mar 2018 05:15:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Aging-a-Given-Population-in-SAS-by-Month/m-p/441119#M282517</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2018-03-01T05:15:17Z</dc:date>
    </item>
  </channel>
</rss>

