<?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: Create a variable number of new lines by and ID dependent on months to a certain date in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Create-a-variable-number-of-new-lines-by-and-ID-dependent-on/m-p/540942#M149292</link>
    <description>&lt;P&gt;You can use either the string date or the number date. The trick is turning the string date into a number date &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data work.have;
label id = "ID";
informat Rawdate date9.;
format Rawdate NowNumberdate yymmd7.;
length StringDate $7;
input id Rawdate StringDate $;

NowNumberdate = input(  compress(stringdate,,'kd') , yymmn6. );

datalines;
5134223 1OCT2018 2018-10
;
run;



data work.want;
set work.have;
output;
do until ( coalesce(NowNumberdate,"1dec2018"d) ge "1dec2018"d);
	NowNumberdate = intnx('month', NowNumberdate,1);
		output;
end;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Wed, 06 Mar 2019 21:55:18 GMT</pubDate>
    <dc:creator>DanielLangley</dc:creator>
    <dc:date>2019-03-06T21:55:18Z</dc:date>
    <item>
      <title>Create a variable number of new lines by and ID dependent on months to a certain date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-a-variable-number-of-new-lines-by-and-ID-dependent-on/m-p/540897#M149265</link>
      <description>&lt;P&gt;First post here, so sorry about formatting/missing details.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a data set that is just a numeric ID and a month value that is a string in format YYYY-M (e.g. September 2017 would be 2017-9). All of the values are in 2017 or 2018. I need to create a row for each ID for each month from the value provided up to December 2018. I also have these dates in a raw date format as well if that would make this easier.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So for example, the input&lt;/P&gt;&lt;PRE class=" language-sas"&gt;&lt;CODE class="  language-sas"&gt;&lt;SPAN class="token datalines"&gt;&lt;SPAN class="token data string"&gt;5134223&amp;nbsp;2018-10&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;Would need to output&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE class=" language-sas"&gt;&lt;CODE class="  language-sas"&gt;&lt;SPAN class="token datalines"&gt;&lt;SPAN class="token data string"&gt;5134223&amp;nbsp;2018-10 &lt;BR /&gt;&lt;BR /&gt;5134223&amp;nbsp;2018-11 &lt;BR /&gt;&lt;BR /&gt;5134223&amp;nbsp;2018-12 &lt;BR /&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;^having trouble with the formatting here but these should be on 3 separate lines.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If anyone can provide any help that would be amazing. Again, I can get these dates in a normal date format but the way I have been approaching it was going to use it as a string until I got stuck.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 06 Mar 2019 19:35:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-a-variable-number-of-new-lines-by-and-ID-dependent-on/m-p/540897#M149265</guid>
      <dc:creator>pfdjadsfdsafas</dc:creator>
      <dc:date>2019-03-06T19:35:15Z</dc:date>
    </item>
    <item>
      <title>Re: Create a variable number of new lines by and ID dependent on months to a certain date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-a-variable-number-of-new-lines-by-and-ID-dependent-on/m-p/540935#M149287</link>
      <description>&lt;P&gt;Few hints:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;1) separate year (informat 4.) from month (informat best2.);&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;2) Create sas date using function MDY()&amp;nbsp; &amp;nbsp;-&amp;nbsp; startDate = mdy(month, 01, year);&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;3) Use DO loop UNTIL (date = '01DEC2018'd); advance date by INTNX() function:&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; date = intnx('month', date,1);&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;4) output each date created in the loop.&lt;/P&gt;</description>
      <pubDate>Wed, 06 Mar 2019 21:35:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-a-variable-number-of-new-lines-by-and-ID-dependent-on/m-p/540935#M149287</guid>
      <dc:creator>Shmuel</dc:creator>
      <dc:date>2019-03-06T21:35:13Z</dc:date>
    </item>
    <item>
      <title>Re: Create a variable number of new lines by and ID dependent on months to a certain date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-a-variable-number-of-new-lines-by-and-ID-dependent-on/m-p/540942#M149292</link>
      <description>&lt;P&gt;You can use either the string date or the number date. The trick is turning the string date into a number date &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data work.have;
label id = "ID";
informat Rawdate date9.;
format Rawdate NowNumberdate yymmd7.;
length StringDate $7;
input id Rawdate StringDate $;

NowNumberdate = input(  compress(stringdate,,'kd') , yymmn6. );

datalines;
5134223 1OCT2018 2018-10
;
run;



data work.want;
set work.have;
output;
do until ( coalesce(NowNumberdate,"1dec2018"d) ge "1dec2018"d);
	NowNumberdate = intnx('month', NowNumberdate,1);
		output;
end;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 06 Mar 2019 21:55:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-a-variable-number-of-new-lines-by-and-ID-dependent-on/m-p/540942#M149292</guid>
      <dc:creator>DanielLangley</dc:creator>
      <dc:date>2019-03-06T21:55:18Z</dc:date>
    </item>
  </channel>
</rss>

