<?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: Populating missing months in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Populating-missing-months/m-p/542730#M149975</link>
    <description>&lt;P&gt;Always use SAS dates, so you can make use of the relevant functions and formats:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
set have;
monthperiod = input(put(start,6.),yymmn6.);
format monthperiod yymmn6.;
output;
do while (monthperiod &amp;lt;= input(put(end,6.),yymmn6.));
  monthperiod = intnx('month',monthperiod,1,'b');
  output;
end;
keep obj monthperiod;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Wed, 13 Mar 2019 11:41:22 GMT</pubDate>
    <dc:creator>Kurt_Bremser</dc:creator>
    <dc:date>2019-03-13T11:41:22Z</dc:date>
    <item>
      <title>Populating missing months</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Populating-missing-months/m-p/542691#M149960</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am trying to populate periods instead of having start and end periods.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Something like this if you get the idea?&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;DATA have;&lt;BR /&gt;INPUT obj $10. start end;&lt;BR /&gt;CARDS;&lt;BR /&gt;PA19460-1 201108 201202&lt;BR /&gt;PA19460-2 201202 201209&lt;BR /&gt;PA19460-3 201209 201705&lt;BR /&gt;PA19460-4 201705 201809&lt;BR /&gt;TR56351-1 201308 201408&lt;BR /&gt;TR56351-2 201408 201409&lt;BR /&gt;KJ92100-1 201101 201201&lt;BR /&gt;;&lt;BR /&gt;RUN;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;DATA want;&lt;BR /&gt;INPUT obj $10. monthperiod ;&lt;BR /&gt;CARDS;&lt;BR /&gt;PA19460-1 201108&lt;BR /&gt;PA19460-1 201109&lt;BR /&gt;PA19460-1 201110&lt;BR /&gt;PA19460-1 201111&lt;BR /&gt;PA19460-1 201112&lt;BR /&gt;PA19460-1 201201&lt;BR /&gt;PA19460-1 201201&lt;BR /&gt;PA19460-1 201202&lt;BR /&gt;PA19460-2 201203&lt;BR /&gt;PA19460-2 201204&lt;BR /&gt;PA19460-2 201205&lt;BR /&gt;PA19460-2 201206&lt;BR /&gt;PA19460-2 201207&lt;BR /&gt;PA19460-2 201208&lt;BR /&gt;PA19460-2 201209&lt;BR /&gt;PA19460-3 201210&lt;BR /&gt;PA19460-3 201211&lt;BR /&gt;PA19460-3 201212&lt;BR /&gt;...etc&lt;BR /&gt;TR56351-1 201308&lt;BR /&gt;TR56351-1 201309&lt;BR /&gt;TR56351-1 201310&lt;BR /&gt;TR56351-1 201311&lt;BR /&gt;TR56351-1 201312&lt;BR /&gt;TR56351-1 201401&lt;BR /&gt;TR56351-1 201402&lt;BR /&gt;TR56351-1 201403&lt;BR /&gt;TR56351-1 201404&lt;BR /&gt;TR56351-1 201405&lt;BR /&gt;TR56351-1 201406&lt;BR /&gt;TR56351-1 201407&lt;BR /&gt;TR56351-1 201408&lt;BR /&gt;TR56351-2 201409&lt;BR /&gt;TR56351-2 201410&lt;/P&gt;
&lt;P&gt;;&lt;BR /&gt;RUN;&lt;/P&gt;</description>
      <pubDate>Wed, 13 Mar 2019 09:13:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Populating-missing-months/m-p/542691#M149960</guid>
      <dc:creator>Kiteulf</dc:creator>
      <dc:date>2019-03-13T09:13:53Z</dc:date>
    </item>
    <item>
      <title>Re: Populating missing months</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Populating-missing-months/m-p/542698#M149961</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
  set have;
  /* Convert Start and End to date values */
  Start_Date = input( left(start),yymmn6.);
  End_Date = input( left(end),yymmn6.);
  format Start_Date End_Date date9.;
  Months = intck('Month',Start_Date,End_Date)+1;
  do m=0 to Months;
    MonthPeriod = put(intnx('Month',Start_Date,m),yymmn6.);
    output;
  end;
  drop Months m Start_Date End_Date start end;
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;I believe the above step should do what you want.&lt;/P&gt;</description>
      <pubDate>Wed, 13 Mar 2019 09:43:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Populating-missing-months/m-p/542698#M149961</guid>
      <dc:creator>MichaelLarsen</dc:creator>
      <dc:date>2019-03-13T09:43:40Z</dc:date>
    </item>
    <item>
      <title>Re: Populating missing months</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Populating-missing-months/m-p/542707#M149964</link>
      <description>&lt;P&gt;You can use a date calculation, as suggested by&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/24960"&gt;@MichaelLarsen&lt;/a&gt; , or you can do it fast and dirty:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
  set have;
  do monthperiod=start by 1;
    if mod(monthperiod,100)=13 then
      monthperiod+88; /* new year, month=1 */
    if monthperiod&amp;gt;end then leave;
    output;
    end;&lt;BR /&gt;  drop start end;
run;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 13 Mar 2019 10:00:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Populating-missing-months/m-p/542707#M149964</guid>
      <dc:creator>s_lassen</dc:creator>
      <dc:date>2019-03-13T10:00:51Z</dc:date>
    </item>
    <item>
      <title>Re: Populating missing months</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Populating-missing-months/m-p/542719#M149972</link>
      <description>&lt;P&gt;Thanks&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Just need to correct for having a double month at the end of each obj, monthperiod&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 13 Mar 2019 10:57:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Populating-missing-months/m-p/542719#M149972</guid>
      <dc:creator>Kiteulf</dc:creator>
      <dc:date>2019-03-13T10:57:00Z</dc:date>
    </item>
    <item>
      <title>Re: Populating missing months</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Populating-missing-months/m-p/542730#M149975</link>
      <description>&lt;P&gt;Always use SAS dates, so you can make use of the relevant functions and formats:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
set have;
monthperiod = input(put(start,6.),yymmn6.);
format monthperiod yymmn6.;
output;
do while (monthperiod &amp;lt;= input(put(end,6.),yymmn6.));
  monthperiod = intnx('month',monthperiod,1,'b');
  output;
end;
keep obj monthperiod;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 13 Mar 2019 11:41:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Populating-missing-months/m-p/542730#M149975</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2019-03-13T11:41:22Z</dc:date>
    </item>
  </channel>
</rss>

