<?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: Do loops in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Do-loops/m-p/335313#M75877</link>
    <description>&lt;P&gt;If you really have every month in your input data, then this will work:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
  input sex agegroup popul monyyyy :$7.;
datalines;
1 1 20 Jun2010
1 2 45 Jun2010
1 3 15 Jun2010
2 1 9 Jun2010
2 2 5 Jun2010
2 3 12 Jun2010
1 1 . Jul2010
1 2 . Jul2010
1 3 . Jul2010
2 1 . Jul2010
2 2 . Jul2010
2 3 . Jul2010
1 1 . Aug2010
1 2 . Aug2010
1 3 . Aug2010
2 1 . Aug2010
2 2 . Aug2010
2 3 . Aug2010
1 1 . Sep2010
1 2 . Sep2010
1 3 . Sep2010
2 1 . Sep2010
2 2 . Sep2010
2 3 . Sep2010
run;

data want (drop=increment);
  set have;
  by monyyyy notsorted;
  if first.monyyyy then increment+5;

  array s_by_a {2,3} _temporary_;

  if monyyyy=:'Jun' then do;
    if first.monyyyy then call missing(of s_by_a{*});
      s_by_a{sex,agegroup}=popul;
      increment=0;
  end;
  else popul=s_by_a{sex,agegroup}+increment;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This program creates a 2x3 matrix s_by_a to hold the popul values from each Jun, where SEX is the row dimension and agegroup is the column dimension.&amp;nbsp; Declaring the array as _temporary_ means its value&amp;nbsp; are automatically retained, so can be used for retrieval later.&amp;nbsp; The INCREMENT var starts at 0 for 'Junxxxx', then 5 for 'Julxxxx', 10 for 'Augxxxx', etc.&lt;/P&gt;</description>
    <pubDate>Thu, 23 Feb 2017 15:28:19 GMT</pubDate>
    <dc:creator>mkeintz</dc:creator>
    <dc:date>2017-02-23T15:28:19Z</dc:date>
    <item>
      <title>Do loops</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Do-loops/m-p/335010#M75729</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have monthly dataset for 6 years, an example is given below. I have all data for each year (june). Each month variable &lt;STRONG&gt;popul &lt;/STRONG&gt;increases by a contanst, for example for sex=1 and age_group=1, popul in Jul2010 would be 20+5, in Aug2010 would be 25+5 and so on... How could I do it?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;sex age_group popul date&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;1 1&amp;nbsp;20 Jun2010&lt;/P&gt;
&lt;P&gt;1 2 45 Jun2010&lt;/P&gt;
&lt;P&gt;1 3 15 Jun2010&lt;/P&gt;
&lt;P&gt;2&amp;nbsp;1 9&amp;nbsp;Jun2010&lt;/P&gt;
&lt;P&gt;2&amp;nbsp;2 5 Jun2010&lt;/P&gt;
&lt;P&gt;2&amp;nbsp;3 12&amp;nbsp;Jun2010&lt;/P&gt;
&lt;P&gt;1 1 .&amp;nbsp;Jul2010&lt;/P&gt;
&lt;P&gt;1 2 . Jul2010&lt;/P&gt;
&lt;P&gt;1 3 . Jul2010&lt;/P&gt;
&lt;P&gt;2&amp;nbsp;1 .&amp;nbsp;Jul2010&lt;/P&gt;
&lt;P&gt;2&amp;nbsp;2 .&amp;nbsp;Jul2010&lt;/P&gt;
&lt;P&gt;2&amp;nbsp;3 .&amp;nbsp;Jul2010&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;........&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;1 1 16&amp;nbsp;Jul2011&lt;/P&gt;
&lt;P&gt;1 2 25 Jun2011&lt;/P&gt;
&lt;P&gt;1 3 5 Jun2011&lt;/P&gt;
&lt;P&gt;2&amp;nbsp;1 8&amp;nbsp;Jun2011&lt;/P&gt;
&lt;P&gt;2&amp;nbsp;2 15 Jun2011&lt;/P&gt;
&lt;P&gt;2&amp;nbsp;3 12&amp;nbsp;Jun2011&lt;/P&gt;
&lt;P&gt;..................&lt;/P&gt;
&lt;P&gt;1 1 16&amp;nbsp;Jul2012&lt;/P&gt;
&lt;P&gt;1 2 25 Jun2012&lt;/P&gt;
&lt;P&gt;1 3 5 Jun2012&lt;/P&gt;
&lt;P&gt;2&amp;nbsp;1 8&amp;nbsp;Jun2012&lt;/P&gt;
&lt;P&gt;2&amp;nbsp;2 15 Jun2012&lt;/P&gt;
&lt;P&gt;2&amp;nbsp;3 12&amp;nbsp;Jun2012&lt;/P&gt;
&lt;P&gt;...................................&lt;/P&gt;</description>
      <pubDate>Wed, 22 Feb 2017 16:10:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Do-loops/m-p/335010#M75729</guid>
      <dc:creator>viollete</dc:creator>
      <dc:date>2017-02-22T16:10:51Z</dc:date>
    </item>
    <item>
      <title>Re: Do loops</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Do-loops/m-p/335058#M75751</link>
      <description>&lt;P&gt;So you need a way to interpolate the monthly values between the years? They most likely won't line up, how to account for that?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Can you clearly show what you expect as output based on the data you've posted. And preferable post in a data step in the future.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Is your date a SAS date or a Character variable?&lt;/P&gt;</description>
      <pubDate>Wed, 22 Feb 2017 18:29:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Do-loops/m-p/335058#M75751</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-02-22T18:29:22Z</dc:date>
    </item>
    <item>
      <title>Re: Do loops</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Do-loops/m-p/335214#M75845</link>
      <description>&lt;P&gt;&lt;STRONG&gt;So I have data similar to this forma&lt;/STRONG&gt;t:&lt;/P&gt;
&lt;P style="margin: 0cm; margin-bottom: .0001pt; line-height: 15.75pt; background: #F4F4F4;"&gt;&lt;SPAN style="font-size: 10.5pt; font-family: 'Helvetica','sans-serif'; color: #333333;"&gt;1 1&amp;nbsp;20 Jun2010&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="margin: 0cm; margin-bottom: .0001pt; line-height: 15.75pt; background: #F4F4F4; box-sizing: inherit; font-variant-ligatures: normal; font-variant-caps: normal; orphans: 2; widows: 2; -webkit-text-stroke-width: 0px; word-spacing: 0px;"&gt;&lt;SPAN style="font-size: 10.5pt; font-family: 'Helvetica','sans-serif'; color: #333333;"&gt;1 2 45 Jun2010&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="margin: 0cm; margin-bottom: .0001pt; line-height: 15.75pt; background: #F4F4F4; box-sizing: inherit; font-variant-ligatures: normal; font-variant-caps: normal; orphans: 2; widows: 2; -webkit-text-stroke-width: 0px; word-spacing: 0px;"&gt;&lt;SPAN style="font-size: 10.5pt; font-family: 'Helvetica','sans-serif'; color: #333333;"&gt;1 3 15 Jun2010&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="margin: 0cm; margin-bottom: .0001pt; line-height: 15.75pt; background: #F4F4F4; box-sizing: inherit; font-variant-ligatures: normal; font-variant-caps: normal; orphans: 2; widows: 2; -webkit-text-stroke-width: 0px; word-spacing: 0px;"&gt;&lt;SPAN style="font-size: 10.5pt; font-family: 'Helvetica','sans-serif'; color: #333333;"&gt;2&amp;nbsp;1 9&amp;nbsp;Jun2010&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="margin: 0cm; margin-bottom: .0001pt; line-height: 15.75pt; background: #F4F4F4; box-sizing: inherit; font-variant-ligatures: normal; font-variant-caps: normal; orphans: 2; widows: 2; -webkit-text-stroke-width: 0px; word-spacing: 0px;"&gt;&lt;SPAN style="font-size: 10.5pt; font-family: 'Helvetica','sans-serif'; color: #333333;"&gt;2&amp;nbsp;2 5 Jun2010&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="margin: 0cm; margin-bottom: .0001pt; line-height: 15.75pt; background: #F4F4F4; box-sizing: inherit; font-variant-ligatures: normal; font-variant-caps: normal; orphans: 2; widows: 2; -webkit-text-stroke-width: 0px; word-spacing: 0px;"&gt;&lt;SPAN style="font-size: 10.5pt; font-family: 'Helvetica','sans-serif'; color: #333333;"&gt;2&amp;nbsp;3 12&amp;nbsp;Jun2010&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="margin: 0cm; margin-bottom: .0001pt; line-height: 15.75pt; background: #F4F4F4; box-sizing: inherit; font-variant-ligatures: normal; font-variant-caps: normal; orphans: 2; widows: 2; -webkit-text-stroke-width: 0px; word-spacing: 0px;"&gt;&lt;SPAN style="font-size: 10.5pt; font-family: 'Helvetica','sans-serif'; color: #333333;"&gt;1 1 .&amp;nbsp;Jul2010&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="margin: 0cm; margin-bottom: .0001pt; line-height: 15.75pt; background: #F4F4F4; box-sizing: inherit; font-variant-ligatures: normal; font-variant-caps: normal; orphans: 2; widows: 2; -webkit-text-stroke-width: 0px; word-spacing: 0px;"&gt;&lt;SPAN style="font-size: 10.5pt; font-family: 'Helvetica','sans-serif'; color: #333333;"&gt;1 2 . Jul2010&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="margin: 0cm; margin-bottom: .0001pt; line-height: 15.75pt; background: #F4F4F4; box-sizing: inherit; font-variant-ligatures: normal; font-variant-caps: normal; orphans: 2; widows: 2; -webkit-text-stroke-width: 0px; word-spacing: 0px;"&gt;&lt;SPAN style="font-size: 10.5pt; font-family: 'Helvetica','sans-serif'; color: #333333;"&gt;1 3 . Jul2010&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="margin: 0cm; margin-bottom: .0001pt; line-height: 15.75pt; background: #F4F4F4; box-sizing: inherit; font-variant-ligatures: normal; font-variant-caps: normal; orphans: 2; widows: 2; -webkit-text-stroke-width: 0px; word-spacing: 0px;"&gt;&lt;SPAN style="font-size: 10.5pt; font-family: 'Helvetica','sans-serif'; color: #333333;"&gt;2&amp;nbsp;1 .&amp;nbsp;Jul2010&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="margin: 0cm; margin-bottom: .0001pt; line-height: 15.75pt; background: #F4F4F4; box-sizing: inherit; font-variant-ligatures: normal; font-variant-caps: normal; orphans: 2; widows: 2; -webkit-text-stroke-width: 0px; word-spacing: 0px;"&gt;&lt;SPAN style="font-size: 10.5pt; font-family: 'Helvetica','sans-serif'; color: #333333;"&gt;2&amp;nbsp;2 .&amp;nbsp;Jul2010&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="margin: 0cm; margin-bottom: .0001pt; line-height: 15.75pt; background: #F4F4F4; box-sizing: inherit; font-variant-ligatures: normal; font-variant-caps: normal; orphans: 2; widows: 2; -webkit-text-stroke-width: 0px; word-spacing: 0px;"&gt;&lt;SPAN style="font-size: 10.5pt; font-family: 'Helvetica','sans-serif'; color: #333333;"&gt;2&amp;nbsp;3 .&amp;nbsp;Jul2010&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="margin: 0cm; margin-bottom: .0001pt; line-height: 15.75pt; background: #F4F4F4;"&gt;&lt;SPAN style="font-size: 10.5pt; font-family: 'Helvetica','sans-serif'; color: #333333;"&gt;1 1 .&amp;nbsp;Aug2010&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="margin: 0cm; margin-bottom: .0001pt; line-height: 15.75pt; background: #F4F4F4; box-sizing: inherit; font-variant-ligatures: normal; font-variant-caps: normal; orphans: 2; widows: 2; -webkit-text-stroke-width: 0px; word-spacing: 0px;"&gt;&lt;SPAN style="font-size: 10.5pt; font-family: 'Helvetica','sans-serif'; color: #333333;"&gt;1 2 . Aug2010&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="margin: 0cm; margin-bottom: .0001pt; line-height: 15.75pt; background: #F4F4F4; box-sizing: inherit; font-variant-ligatures: normal; font-variant-caps: normal; orphans: 2; widows: 2; -webkit-text-stroke-width: 0px; word-spacing: 0px;"&gt;&lt;SPAN style="font-size: 10.5pt; font-family: 'Helvetica','sans-serif'; color: #333333;"&gt;1 3 . Aug2010&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="margin: 0cm; margin-bottom: .0001pt; line-height: 15.75pt; background: #F4F4F4; box-sizing: inherit; font-variant-ligatures: normal; font-variant-caps: normal; orphans: 2; widows: 2; -webkit-text-stroke-width: 0px; word-spacing: 0px;"&gt;&lt;SPAN style="font-size: 10.5pt; font-family: 'Helvetica','sans-serif'; color: #333333;"&gt;2&amp;nbsp;1 .&amp;nbsp;Aug2010&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="margin: 0cm; margin-bottom: .0001pt; line-height: 15.75pt; background: #F4F4F4; box-sizing: inherit; font-variant-ligatures: normal; font-variant-caps: normal; orphans: 2; widows: 2; -webkit-text-stroke-width: 0px; word-spacing: 0px;"&gt;&lt;SPAN style="font-size: 10.5pt; font-family: 'Helvetica','sans-serif'; color: #333333;"&gt;2&amp;nbsp;2 .&amp;nbsp;Aug2010&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="margin: 0cm; margin-bottom: .0001pt; line-height: 15.75pt; background: #F4F4F4; box-sizing: inherit; font-variant-ligatures: normal; font-variant-caps: normal; orphans: 2; widows: 2; -webkit-text-stroke-width: 0px; word-spacing: 0px;"&gt;&lt;SPAN style="font-size: 10.5pt; font-family: 'Helvetica','sans-serif'; color: #333333;"&gt;2&amp;nbsp;3 .&amp;nbsp;Aug2010&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="margin: 0cm; margin-bottom: .0001pt; line-height: 15.75pt; background: #F4F4F4;"&gt;&lt;SPAN style="font-size: 10.5pt; font-family: 'Helvetica','sans-serif'; color: #333333;"&gt;1 1 .&amp;nbsp;Sep2010&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="margin: 0cm; margin-bottom: .0001pt; line-height: 15.75pt; background: #F4F4F4; box-sizing: inherit; font-variant-ligatures: normal; font-variant-caps: normal; orphans: 2; widows: 2; -webkit-text-stroke-width: 0px; word-spacing: 0px;"&gt;&lt;SPAN style="font-size: 10.5pt; font-family: 'Helvetica','sans-serif'; color: #333333;"&gt;1 2 . Sep2010&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="margin: 0cm; margin-bottom: .0001pt; line-height: 15.75pt; background: #F4F4F4; box-sizing: inherit; font-variant-ligatures: normal; font-variant-caps: normal; orphans: 2; widows: 2; -webkit-text-stroke-width: 0px; word-spacing: 0px;"&gt;&lt;SPAN style="font-size: 10.5pt; font-family: 'Helvetica','sans-serif'; color: #333333;"&gt;1 3 . Sep2010&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="margin: 0cm; margin-bottom: .0001pt; line-height: 15.75pt; background: #F4F4F4; box-sizing: inherit; font-variant-ligatures: normal; font-variant-caps: normal; orphans: 2; widows: 2; -webkit-text-stroke-width: 0px; word-spacing: 0px;"&gt;&lt;SPAN style="font-size: 10.5pt; font-family: 'Helvetica','sans-serif'; color: #333333;"&gt;2&amp;nbsp;1 .&amp;nbsp;Sep2010&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="margin: 0cm; margin-bottom: .0001pt; line-height: 15.75pt; background: #F4F4F4; box-sizing: inherit; font-variant-ligatures: normal; font-variant-caps: normal; orphans: 2; widows: 2; -webkit-text-stroke-width: 0px; word-spacing: 0px;"&gt;&lt;SPAN style="font-size: 10.5pt; font-family: 'Helvetica','sans-serif'; color: #333333;"&gt;2&amp;nbsp;2 .&amp;nbsp;Sep2010&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="margin: 0cm; margin-bottom: .0001pt; line-height: 15.75pt; background: #F4F4F4; box-sizing: inherit; font-variant-ligatures: normal; font-variant-caps: normal; orphans: 2; widows: 2; -webkit-text-stroke-width: 0px; word-spacing: 0px;"&gt;&lt;SPAN style="font-size: 10.5pt; font-family: 'Helvetica','sans-serif'; color: #333333;"&gt;2&amp;nbsp;3 .&amp;nbsp;Sep2010&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="margin: 0cm; margin-bottom: .0001pt; line-height: 15.75pt; background: #F4F4F4;"&gt;&lt;SPAN style="font-size: 10.5pt; font-family: 'Helvetica','sans-serif'; color: #333333;"&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="margin: 0cm; margin-bottom: .0001pt; line-height: 15.75pt; background: #F4F4F4;"&gt;&lt;SPAN style="font-size: 10.5pt; font-family: 'Helvetica','sans-serif'; color: #333333;"&gt;&lt;STRONG&gt;And I want it to be like this&lt;/STRONG&gt;:&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="margin: 0cm; margin-bottom: .0001pt; line-height: 15.75pt; background: #F4F4F4;"&gt;&lt;SPAN style="font-size: 10.5pt; font-family: 'Helvetica','sans-serif'; color: #333333;"&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="margin: 0cm; margin-bottom: .0001pt; line-height: 15.75pt; background: #F4F4F4;"&gt;&lt;SPAN style="font-size: 10.5pt; font-family: 'Helvetica','sans-serif'; color: #333333;"&gt;1 1&amp;nbsp;20 Jun2010&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="margin: 0cm; margin-bottom: .0001pt; line-height: 15.75pt; background: #F4F4F4; box-sizing: inherit; font-variant-ligatures: normal; font-variant-caps: normal; orphans: 2; widows: 2; -webkit-text-stroke-width: 0px; word-spacing: 0px;"&gt;&lt;SPAN style="font-size: 10.5pt; font-family: 'Helvetica','sans-serif'; color: #333333;"&gt;1 2 45 Jun2010&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="margin: 0cm; margin-bottom: .0001pt; line-height: 15.75pt; background: #F4F4F4; box-sizing: inherit; font-variant-ligatures: normal; font-variant-caps: normal; orphans: 2; widows: 2; -webkit-text-stroke-width: 0px; word-spacing: 0px;"&gt;&lt;SPAN style="font-size: 10.5pt; font-family: 'Helvetica','sans-serif'; color: #333333;"&gt;1 3 15 Jun2010&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="margin: 0cm; margin-bottom: .0001pt; line-height: 15.75pt; background: #F4F4F4; box-sizing: inherit; font-variant-ligatures: normal; font-variant-caps: normal; orphans: 2; widows: 2; -webkit-text-stroke-width: 0px; word-spacing: 0px;"&gt;&lt;SPAN style="font-size: 10.5pt; font-family: 'Helvetica','sans-serif'; color: #333333;"&gt;2&amp;nbsp;1 9&amp;nbsp;Jun2010&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="margin: 0cm; margin-bottom: .0001pt; line-height: 15.75pt; background: #F4F4F4; box-sizing: inherit; font-variant-ligatures: normal; font-variant-caps: normal; orphans: 2; widows: 2; -webkit-text-stroke-width: 0px; word-spacing: 0px;"&gt;&lt;SPAN style="font-size: 10.5pt; font-family: 'Helvetica','sans-serif'; color: #333333;"&gt;2&amp;nbsp;2 5 Jun2010&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="margin: 0cm; margin-bottom: .0001pt; line-height: 15.75pt; background: #F4F4F4; box-sizing: inherit; font-variant-ligatures: normal; font-variant-caps: normal; orphans: 2; widows: 2; -webkit-text-stroke-width: 0px; word-spacing: 0px;"&gt;&lt;SPAN style="font-size: 10.5pt; font-family: 'Helvetica','sans-serif'; color: #333333;"&gt;2&amp;nbsp;3 12&amp;nbsp;Jun2010&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="margin: 0cm; margin-bottom: .0001pt; line-height: 15.75pt; background: #F4F4F4; box-sizing: inherit; font-variant-ligatures: normal; font-variant-caps: normal; orphans: 2; widows: 2; -webkit-text-stroke-width: 0px; word-spacing: 0px;"&gt;&lt;SPAN style="font-size: 10.5pt; font-family: 'Helvetica','sans-serif'; color: #333333;"&gt;1 1 25 Jul2010&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="margin: 0cm; margin-bottom: .0001pt; line-height: 15.75pt; background: #F4F4F4; box-sizing: inherit; font-variant-ligatures: normal; font-variant-caps: normal; orphans: 2; widows: 2; -webkit-text-stroke-width: 0px; word-spacing: 0px;"&gt;&lt;SPAN style="font-size: 10.5pt; font-family: 'Helvetica','sans-serif'; color: #333333;"&gt;1 2 46 Jul2010&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="margin: 0cm; margin-bottom: .0001pt; line-height: 15.75pt; background: #F4F4F4; box-sizing: inherit; font-variant-ligatures: normal; font-variant-caps: normal; orphans: 2; widows: 2; -webkit-text-stroke-width: 0px; word-spacing: 0px;"&gt;&lt;SPAN style="font-size: 10.5pt; font-family: 'Helvetica','sans-serif'; color: #333333;"&gt;1 3 17 Jul2010&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="margin: 0cm; margin-bottom: .0001pt; line-height: 15.75pt; background: #F4F4F4; box-sizing: inherit; font-variant-ligatures: normal; font-variant-caps: normal; orphans: 2; widows: 2; -webkit-text-stroke-width: 0px; word-spacing: 0px;"&gt;&lt;SPAN style="font-size: 10.5pt; font-family: 'Helvetica','sans-serif'; color: #333333;"&gt;2&amp;nbsp;1 8&amp;nbsp;Jul2010&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="margin: 0cm; margin-bottom: .0001pt; line-height: 15.75pt; background: #F4F4F4; box-sizing: inherit; font-variant-ligatures: normal; font-variant-caps: normal; orphans: 2; widows: 2; -webkit-text-stroke-width: 0px; word-spacing: 0px;"&gt;&lt;SPAN style="font-size: 10.5pt; font-family: 'Helvetica','sans-serif'; color: #333333;"&gt;2&amp;nbsp;2 6&amp;nbsp;Jul2010&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="margin: 0cm; margin-bottom: .0001pt; line-height: 15.75pt; background: #F4F4F4; box-sizing: inherit; font-variant-ligatures: normal; font-variant-caps: normal; orphans: 2; widows: 2; -webkit-text-stroke-width: 0px; word-spacing: 0px;"&gt;&lt;SPAN style="font-size: 10.5pt; font-family: 'Helvetica','sans-serif'; color: #333333;"&gt;2&amp;nbsp;3 17&amp;nbsp;Jul2010&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="margin: 0cm; margin-bottom: .0001pt; line-height: 15.75pt; background: #F4F4F4;"&gt;&lt;SPAN style="font-size: 10.5pt; font-family: 'Helvetica','sans-serif'; color: #333333;"&gt;1 1 30&amp;nbsp;Aug2010&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="margin: 0cm; margin-bottom: .0001pt; line-height: 15.75pt; background: #F4F4F4; box-sizing: inherit; font-variant-ligatures: normal; font-variant-caps: normal; orphans: 2; widows: 2; -webkit-text-stroke-width: 0px; word-spacing: 0px;"&gt;&lt;SPAN style="font-size: 10.5pt; font-family: 'Helvetica','sans-serif'; color: #333333;"&gt;1 2 47 Aug2010&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="margin: 0cm; margin-bottom: .0001pt; line-height: 15.75pt; background: #F4F4F4; box-sizing: inherit; font-variant-ligatures: normal; font-variant-caps: normal; orphans: 2; widows: 2; -webkit-text-stroke-width: 0px; word-spacing: 0px;"&gt;&lt;SPAN style="font-size: 10.5pt; font-family: 'Helvetica','sans-serif'; color: #333333;"&gt;1 3 19 Aug2010&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="margin: 0cm; margin-bottom: .0001pt; line-height: 15.75pt; background: #F4F4F4; box-sizing: inherit; font-variant-ligatures: normal; font-variant-caps: normal; orphans: 2; widows: 2; -webkit-text-stroke-width: 0px; word-spacing: 0px;"&gt;&lt;SPAN style="font-size: 10.5pt; font-family: 'Helvetica','sans-serif'; color: #333333;"&gt;2&amp;nbsp;1 7&amp;nbsp;Aug2010&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="margin: 0cm; margin-bottom: .0001pt; line-height: 15.75pt; background: #F4F4F4; box-sizing: inherit; font-variant-ligatures: normal; font-variant-caps: normal; orphans: 2; widows: 2; -webkit-text-stroke-width: 0px; word-spacing: 0px;"&gt;&lt;SPAN style="font-size: 10.5pt; font-family: 'Helvetica','sans-serif'; color: #333333;"&gt;2&amp;nbsp;2 7&amp;nbsp;Aug2010&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="margin: 0cm; margin-bottom: .0001pt; line-height: 15.75pt; background: #F4F4F4; box-sizing: inherit; font-variant-ligatures: normal; font-variant-caps: normal; orphans: 2; widows: 2; -webkit-text-stroke-width: 0px; word-spacing: 0px;"&gt;&lt;SPAN style="font-size: 10.5pt; font-family: 'Helvetica','sans-serif'; color: #333333;"&gt;2&amp;nbsp;3 22&amp;nbsp;Aug2010&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="margin: 0cm; margin-bottom: .0001pt; line-height: 15.75pt; background: #F4F4F4;"&gt;&lt;SPAN style="font-size: 10.5pt; font-family: 'Helvetica','sans-serif'; color: #333333;"&gt;1 1 35&amp;nbsp;Sep2010&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="margin: 0cm; margin-bottom: .0001pt; line-height: 15.75pt; background: #F4F4F4; box-sizing: inherit; font-variant-ligatures: normal; font-variant-caps: normal; orphans: 2; widows: 2; -webkit-text-stroke-width: 0px; word-spacing: 0px;"&gt;&lt;SPAN style="font-size: 10.5pt; font-family: 'Helvetica','sans-serif'; color: #333333;"&gt;1 2 47 Sep2010&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="margin: 0cm; margin-bottom: .0001pt; line-height: 15.75pt; background: #F4F4F4; box-sizing: inherit; font-variant-ligatures: normal; font-variant-caps: normal; orphans: 2; widows: 2; -webkit-text-stroke-width: 0px; word-spacing: 0px;"&gt;&lt;SPAN style="font-size: 10.5pt; font-family: 'Helvetica','sans-serif'; color: #333333;"&gt;1 3 21 Sep2010&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="margin: 0cm; margin-bottom: .0001pt; line-height: 15.75pt; background: #F4F4F4; box-sizing: inherit; font-variant-ligatures: normal; font-variant-caps: normal; orphans: 2; widows: 2; -webkit-text-stroke-width: 0px; word-spacing: 0px;"&gt;&lt;SPAN style="font-size: 10.5pt; font-family: 'Helvetica','sans-serif'; color: #333333;"&gt;2&amp;nbsp;1 6&amp;nbsp;Sep2010&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="margin: 0cm; margin-bottom: .0001pt; line-height: 15.75pt; background: #F4F4F4; box-sizing: inherit; font-variant-ligatures: normal; font-variant-caps: normal; orphans: 2; widows: 2; -webkit-text-stroke-width: 0px; word-spacing: 0px;"&gt;&lt;SPAN style="font-size: 10.5pt; font-family: 'Helvetica','sans-serif'; color: #333333;"&gt;2&amp;nbsp;2 8&amp;nbsp;Sep2010&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="margin: 0cm; margin-bottom: .0001pt; line-height: 15.75pt; background: #F4F4F4; box-sizing: inherit; font-variant-ligatures: normal; font-variant-caps: normal; orphans: 2; widows: 2; -webkit-text-stroke-width: 0px; word-spacing: 0px;"&gt;&lt;SPAN style="font-size: 10.5pt; font-family: 'Helvetica','sans-serif'; color: #333333;"&gt;2&amp;nbsp;3 27&amp;nbsp;Sep2010&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="margin: 0cm; margin-bottom: .0001pt; line-height: 15.75pt; background: #F4F4F4;"&gt;&lt;SPAN style="font-size: 10.5pt; font-family: 'Helvetica','sans-serif'; color: #333333;"&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="margin: 0cm; margin-bottom: .0001pt; line-height: 15.75pt; background: #F4F4F4;"&gt;&lt;SPAN style="font-size: 10.5pt; font-family: 'Helvetica','sans-serif'; color: #333333;"&gt;My date variable is in MONYY7. format&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 23 Feb 2017 08:30:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Do-loops/m-p/335214#M75845</guid>
      <dc:creator>viollete</dc:creator>
      <dc:date>2017-02-23T08:30:39Z</dc:date>
    </item>
    <item>
      <title>Re: Do loops</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Do-loops/m-p/335225#M75849</link>
      <description>&lt;P&gt;How do you know what constant to use or how many times to loop?&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can use a multiple output statement per record you have but need to know how to change it.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Output;&lt;/P&gt;
&lt;P&gt;Do i=1 to 11;&lt;/P&gt;
&lt;P&gt;date=INTNX('month', DATE, I, , 'S');&lt;/P&gt;
&lt;P&gt;value = value + 5;&lt;/P&gt;
&lt;P&gt;output;&lt;/P&gt;
&lt;P&gt;end;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 23 Feb 2017 10:21:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Do-loops/m-p/335225#M75849</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-02-23T10:21:46Z</dc:date>
    </item>
    <item>
      <title>Re: Do loops</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Do-loops/m-p/335313#M75877</link>
      <description>&lt;P&gt;If you really have every month in your input data, then this will work:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
  input sex agegroup popul monyyyy :$7.;
datalines;
1 1 20 Jun2010
1 2 45 Jun2010
1 3 15 Jun2010
2 1 9 Jun2010
2 2 5 Jun2010
2 3 12 Jun2010
1 1 . Jul2010
1 2 . Jul2010
1 3 . Jul2010
2 1 . Jul2010
2 2 . Jul2010
2 3 . Jul2010
1 1 . Aug2010
1 2 . Aug2010
1 3 . Aug2010
2 1 . Aug2010
2 2 . Aug2010
2 3 . Aug2010
1 1 . Sep2010
1 2 . Sep2010
1 3 . Sep2010
2 1 . Sep2010
2 2 . Sep2010
2 3 . Sep2010
run;

data want (drop=increment);
  set have;
  by monyyyy notsorted;
  if first.monyyyy then increment+5;

  array s_by_a {2,3} _temporary_;

  if monyyyy=:'Jun' then do;
    if first.monyyyy then call missing(of s_by_a{*});
      s_by_a{sex,agegroup}=popul;
      increment=0;
  end;
  else popul=s_by_a{sex,agegroup}+increment;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This program creates a 2x3 matrix s_by_a to hold the popul values from each Jun, where SEX is the row dimension and agegroup is the column dimension.&amp;nbsp; Declaring the array as _temporary_ means its value&amp;nbsp; are automatically retained, so can be used for retrieval later.&amp;nbsp; The INCREMENT var starts at 0 for 'Junxxxx', then 5 for 'Julxxxx', 10 for 'Augxxxx', etc.&lt;/P&gt;</description>
      <pubDate>Thu, 23 Feb 2017 15:28:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Do-loops/m-p/335313#M75877</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2017-02-23T15:28:19Z</dc:date>
    </item>
    <item>
      <title>Re: Do loops</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Do-loops/m-p/335317#M75879</link>
      <description>&lt;P&gt;But the increament for different sex and different age group is different&lt;/P&gt;</description>
      <pubDate>Thu, 23 Feb 2017 15:35:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Do-loops/m-p/335317#M75879</guid>
      <dc:creator>viollete</dc:creator>
      <dc:date>2017-02-23T15:35:10Z</dc:date>
    </item>
    <item>
      <title>Re: Do loops</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Do-loops/m-p/335352#M75887</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/37682"&gt;@viollete&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;But the increament for different sex and different age group is different&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;You didn't say that, you said a constant such as 5.&lt;/P&gt;
&lt;P&gt;What are the rules? Where are they stored?&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 23 Feb 2017 17:13:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Do-loops/m-p/335352#M75887</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-02-23T17:13:06Z</dc:date>
    </item>
  </channel>
</rss>

