<?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: Spreading the dates over the months in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Spreading-the-dates-over-the-months/m-p/796566#M255628</link>
    <description>Works perfectly. Thank you all for support. Sorry for the trouble with the problem description, I should've adjusted the sample set.</description>
    <pubDate>Wed, 16 Feb 2022 14:48:19 GMT</pubDate>
    <dc:creator>PatrykSAS</dc:creator>
    <dc:date>2022-02-16T14:48:19Z</dc:date>
    <item>
      <title>Spreading the dates over the months</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Spreading-the-dates-over-the-months/m-p/796542#M255616</link>
      <description>&lt;P&gt;Hi.&lt;/P&gt;
&lt;P&gt;I want to designate each separate month between two dates. I want to create a row with the year and month between the start and end dates. The maximum I want to create a schedule by 2026, even though the end date may be greater.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
   input id $ start :yymmdd10. stop :yymmdd10.;
   format start yymmddd10.;
   format stop yymmddd10.;
   datalines;
123 2021-02-01 2021-12-31
123 2022-01-01 2022-05-31
123 2022-06-01 9999-12-31
;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
   input id $ start :yymmdd10. stop :yymmdd10. year month;
   format start yymmddd10.;
   format stop yymmddd10.;
   datalines;
123 2021-02-01 2021-12-31 2021 2
123 2021-02-01 2021-12-31 2021 3
123 2021-02-01 2021-12-31 2021 4
123 2022-01-01 2022-05-31 2022 1
123 2022-01-01 2022-05-31 2022 2
123 2022-01-01 2022-05-31 2022 3
123 2022-06-01 9999-12-31 2022 6
123 2022-06-01 9999-12-31 2022 7
123 2022-06-01 9999-12-31 2022 8
;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Data Want is just example, I didn't write out all the lines month by month. Can You help me with solution?&lt;/P&gt;</description>
      <pubDate>Wed, 16 Feb 2022 14:04:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Spreading-the-dates-over-the-months/m-p/796542#M255616</guid>
      <dc:creator>PatrykSAS</dc:creator>
      <dc:date>2022-02-16T14:04:26Z</dc:date>
    </item>
    <item>
      <title>Re: Spreading the dates over the months</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Spreading-the-dates-over-the-months/m-p/796547#M255618</link>
      <description>&lt;P&gt;Why does the last row only become 3 obs in the new data set?&lt;/P&gt;</description>
      <pubDate>Wed, 16 Feb 2022 13:45:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Spreading-the-dates-over-the-months/m-p/796547#M255618</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2022-02-16T13:45:26Z</dc:date>
    </item>
    <item>
      <title>Re: Spreading the dates over the months</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Spreading-the-dates-over-the-months/m-p/796549#M255619</link>
      <description>I just didn't want to write down every possible case and listed the first few</description>
      <pubDate>Wed, 16 Feb 2022 13:51:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Spreading-the-dates-over-the-months/m-p/796549#M255619</guid>
      <dc:creator>PatrykSAS</dc:creator>
      <dc:date>2022-02-16T13:51:56Z</dc:date>
    </item>
    <item>
      <title>Re: Spreading the dates over the months</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Spreading-the-dates-over-the-months/m-p/796550#M255620</link>
      <description>&lt;P&gt;Your WANT dataset seems to be incomplete. For the first row in HAVE, I would expect 11 rows in WANT (2,3,4,5,6,7,8,9,10,11,12), for the second 5 rows, and for the third 55 (7 in 2022 and 4*12 until 2026).&lt;/P&gt;</description>
      <pubDate>Wed, 16 Feb 2022 13:55:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Spreading-the-dates-over-the-months/m-p/796550#M255620</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2022-02-16T13:55:03Z</dc:date>
    </item>
    <item>
      <title>Re: Spreading the dates over the months</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Spreading-the-dates-over-the-months/m-p/796553#M255621</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/315439"&gt;@PatrykSAS&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;I just didn't want to write down every possible case and listed the first few&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;That's not good. It causes us to unnecessarily have doubts about your question, delaying the solution. ALWAYS post complete WANT for your HAVE. ALWAYS.&lt;/P&gt;
&lt;P&gt;See this code:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
set have;
dt = start;
do until (dt &amp;gt; min(stop,'31dec2026'd));
  year = year(dt);
  month = month(dt);
  output;
  dt = intnx('month',dt,1,"e");
end;
drop dt;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 16 Feb 2022 14:03:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Spreading-the-dates-over-the-months/m-p/796553#M255621</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2022-02-16T14:03:26Z</dc:date>
    </item>
    <item>
      <title>Re: Spreading the dates over the months</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Spreading-the-dates-over-the-months/m-p/796554#M255622</link>
      <description>Yes it is. This is just an example not to write out all the lines by hand month by month.</description>
      <pubDate>Wed, 16 Feb 2022 14:03:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Spreading-the-dates-over-the-months/m-p/796554#M255622</guid>
      <dc:creator>PatrykSAS</dc:creator>
      <dc:date>2022-02-16T14:03:30Z</dc:date>
    </item>
    <item>
      <title>Re: Spreading the dates over the months</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Spreading-the-dates-over-the-months/m-p/796555#M255623</link>
      <description>&lt;P&gt;The words of your description doesn't seem to match your output or I have misunderstood.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Your first row should produce all months in 2021 up to month 12, but your output doesn't show that. Please explain.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This code matches your description, but doesn't match your output.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
    set have;
    if stop&amp;gt;'31DEC2026'd then stop='31DEC2026'd;
    do i = 0 to intck('month',start,stop);
        year=year(intnx('month',start,i,'b'));
        month=month(intnx('month',start,i,'b'));
        output;
    end;
    drop i;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 16 Feb 2022 14:10:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Spreading-the-dates-over-the-months/m-p/796555#M255623</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2022-02-16T14:10:20Z</dc:date>
    </item>
    <item>
      <title>Re: Spreading the dates over the months</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Spreading-the-dates-over-the-months/m-p/796556#M255624</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/315439"&gt;@PatrykSAS&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;Yes it is. This is just an example not to write out all the lines by hand month by month.&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;This needs to be stated in the original problem description.&lt;/P&gt;</description>
      <pubDate>Wed, 16 Feb 2022 14:04:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Spreading-the-dates-over-the-months/m-p/796556#M255624</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2022-02-16T14:04:33Z</dc:date>
    </item>
    <item>
      <title>Re: Spreading the dates over the months</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Spreading-the-dates-over-the-months/m-p/796557#M255625</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/315439"&gt;@PatrykSAS&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;Yes it is. This is just an example not to write out all the lines by hand month by month.&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Then you should have adapted the HAVE accordingly.&lt;/P&gt;</description>
      <pubDate>Wed, 16 Feb 2022 14:04:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Spreading-the-dates-over-the-months/m-p/796557#M255625</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2022-02-16T14:04:37Z</dc:date>
    </item>
    <item>
      <title>Re: Spreading the dates over the months</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Spreading-the-dates-over-the-months/m-p/796558#M255626</link>
      <description>&lt;P&gt;I changed your input data a bit. See if this works for you&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
   input id $ start :yymmdd10. stop :yymmdd10.;
   format start yymmddd10.;
   format stop yymmddd10.;
   datalines;
123 2021-02-01 2021-12-31
123 2022-01-01 2022-05-31
123 2022-06-01 2022-12-31
;

data want(drop = i dt);
   set have;
   
   do i = 0 by 1 while (1);
      dt = intnx('month', start, i, 'b');
	  if dt &amp;gt; stop then leave;

	  year = year(dt);
      month = month(dt);
	  output;
	  
   end;
   format dt yymmdd10.;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 16 Feb 2022 14:06:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Spreading-the-dates-over-the-months/m-p/796558#M255626</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2022-02-16T14:06:02Z</dc:date>
    </item>
    <item>
      <title>Re: Spreading the dates over the months</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Spreading-the-dates-over-the-months/m-p/796566#M255628</link>
      <description>Works perfectly. Thank you all for support. Sorry for the trouble with the problem description, I should've adjusted the sample set.</description>
      <pubDate>Wed, 16 Feb 2022 14:48:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Spreading-the-dates-over-the-months/m-p/796566#M255628</guid>
      <dc:creator>PatrykSAS</dc:creator>
      <dc:date>2022-02-16T14:48:19Z</dc:date>
    </item>
  </channel>
</rss>

