<?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: Macro programming - use variable value for stop value in do loop in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Macro-programming-use-variable-value-for-stop-value-in-do-loop/m-p/529409#M144640</link>
    <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159"&gt;@Tom&lt;/a&gt;&amp;nbsp;hit the nail on the head here.&amp;nbsp; Modify this statement:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT size="3"&gt;&lt;FONT face="Courier New"&gt;pdate[i] = intnx(&lt;/FONT&gt;&lt;FONT face="Courier New" color="#800080"&gt;'month'&lt;/FONT&gt;&lt;FONT face="Courier New"&gt;,promise_1_date2,[i],&lt;/FONT&gt;&lt;FONT face="Courier New" color="#800080"&gt;'same'&lt;/FONT&gt;&lt;FONT face="Courier New"&gt;);&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Remove the square brackets within the INTNX function (not anywhere else)::&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT size="3"&gt;&lt;FONT face="Courier New"&gt;pdate[i] = intnx(&lt;/FONT&gt;&lt;FONT face="Courier New" color="#800080"&gt;'month'&lt;/FONT&gt;&lt;FONT face="Courier New"&gt;,promise_1_date2, i ,&lt;/FONT&gt;&lt;FONT face="Courier New" color="#800080"&gt;'same'&lt;/FONT&gt;&lt;FONT face="Courier New"&gt;);&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And, of course, verify that the numbers that you get are correct.&lt;/P&gt;</description>
    <pubDate>Wed, 23 Jan 2019 15:09:10 GMT</pubDate>
    <dc:creator>Astounding</dc:creator>
    <dc:date>2019-01-23T15:09:10Z</dc:date>
    <item>
      <title>Macro programming - use variable value for stop value in do loop</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-programming-use-variable-value-for-stop-value-in-do-loop/m-p/529383#M144631</link>
      <description>&lt;P&gt;Hi, me again!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want to run a macro program in Enterprise Guide with a do loop in it that will populate a certain number of date variables.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The original data set contains from date1 to date7 but I want it to go up to date12, based on the value of the instalments variable in each observation.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My code is: -&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;%macro test;&lt;/P&gt;&lt;P&gt;data test_2;&lt;/P&gt;&lt;P&gt;set test;&lt;/P&gt;&lt;P&gt;format promise_1_date8 promise_1_date9 promise_1_date10 promise_1_date11 promise_1_date12 ddmmyy10.;&lt;/P&gt;&lt;P&gt;%if instalments &amp;gt; 7 %then %do a = 8 %to instalments;&lt;/P&gt;&lt;P&gt;promise_1_date&amp;amp;a. = intnx('month',promise_1_date2,&amp;amp;a.,'same');&lt;/P&gt;&lt;P&gt;%end;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;%mend test;&lt;/P&gt;&lt;P&gt;%test&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Which returns the following errors: -&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;ERROR: A character operand was found in the %EVAL function or %IF condition where a numeric operand is required. The condition was:&lt;/P&gt;&lt;P&gt;instalments&lt;/P&gt;&lt;P&gt;ERROR: The %TO value of the %DO A loop is invalid.&lt;/P&gt;&lt;P&gt;ERROR: The macro TEST will stop executing&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is it possible to use the value of instalments for each observation to populate only that number of dates (leaving the additional date variables&amp;nbsp; blank?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;At the moment I am using %do a=8 %to 12, and then using further if then do statements to reset the unneeded dates to missing but I'm assuming there is a smarter way to do this?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;As always, thanks in advance for any assistance,&lt;/P&gt;&lt;P&gt;Rob&lt;/P&gt;</description>
      <pubDate>Wed, 23 Jan 2019 13:43:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-programming-use-variable-value-for-stop-value-in-do-loop/m-p/529383#M144631</guid>
      <dc:creator>robulon</dc:creator>
      <dc:date>2019-01-23T13:43:47Z</dc:date>
    </item>
    <item>
      <title>Re: Macro programming - use variable value for stop value in do loop</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-programming-use-variable-value-for-stop-value-in-do-loop/m-p/529384#M144632</link>
      <description>&lt;P&gt;Based on what you have described, the program should use base SAS only.&amp;nbsp; You might need to add an ARRAY statement.&amp;nbsp; But you would not need macro language at all.&lt;/P&gt;</description>
      <pubDate>Wed, 23 Jan 2019 13:49:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-programming-use-variable-value-for-stop-value-in-do-loop/m-p/529384#M144632</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2019-01-23T13:49:06Z</dc:date>
    </item>
    <item>
      <title>Re: Macro programming - use variable value for stop value in do loop</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-programming-use-variable-value-for-stop-value-in-do-loop/m-p/529389#M144633</link>
      <description>&lt;P&gt;Thanks.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I've never really used arrays but have given it a go as follows.&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="1"&gt;&lt;STRONG&gt;data&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="1"&gt; test_2;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="1"&gt;set&lt;/FONT&gt;&lt;FONT face="Courier New" size="1"&gt; prom_201812;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="1"&gt;format&lt;/FONT&gt;&lt;FONT face="Courier New" size="1"&gt; promise_1_date8 promise_1_date9 promise_1_date10 promise_1_date11 promise_1_date12 &lt;/FONT&gt;&lt;FONT color="#008080" face="Courier New" size="1"&gt;ddmmyy10.&lt;/FONT&gt;&lt;FONT face="Courier New" size="1"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="1"&gt;array&lt;/FONT&gt;&lt;FONT face="Courier New" size="1"&gt; pdate [&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="1"&gt;5&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="1"&gt;] promise_1_date8 - promise_1_date12;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="1"&gt;array&lt;/FONT&gt;&lt;FONT face="Courier New" size="1"&gt; pamt [&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="1"&gt;5&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="1"&gt;] promise_1_amt8 - promise_1_amt12;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="1"&gt;if&lt;/FONT&gt;&lt;FONT face="Courier New" size="1"&gt; instalments &amp;gt; &lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="1"&gt;7&lt;/FONT&gt;&lt;/STRONG&gt; &lt;FONT color="#0000ff" face="Courier New" size="1"&gt;then&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Courier New" size="1"&gt;do&lt;/FONT&gt;&lt;FONT face="Courier New" size="1"&gt; i = &lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="1"&gt;8&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="1"&gt; to &lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="1"&gt;12&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="1"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="1"&gt;pdate[i] = intnx(&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="1"&gt;'month'&lt;/FONT&gt;&lt;FONT face="Courier New" size="1"&gt;,promise_1_date2,[i],&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="1"&gt;'same'&lt;/FONT&gt;&lt;FONT face="Courier New" size="1"&gt;);&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;pamt[i] = promise_1_amt2;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="1"&gt;end&lt;/FONT&gt;&lt;FONT face="Courier New" size="1"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="1"&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="1"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The problem now is that the array doesn't seem to&amp;nbsp;like me having a constant variable value (promise_1_date2) as the reference point from which to calculate the other dates, as I get this in the log: -&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;39 if instalments &amp;gt; 7 then do i = 8 to 12;&lt;/P&gt;&lt;P&gt;40 pdate[i] = intnx('month',promise_1_date2,[i],'same');&lt;/P&gt;&lt;P&gt;_&lt;/P&gt;&lt;P&gt;22&lt;/P&gt;&lt;P&gt;ERROR: Undeclared array referenced: NAME.&lt;/P&gt;&lt;P&gt;ERROR: Variable NAME has not been declared as an array.&lt;/P&gt;&lt;P&gt;ERROR 22-322: Syntax error, expecting one of the following: a name, INPUT, PUT.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 23 Jan 2019 14:25:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-programming-use-variable-value-for-stop-value-in-do-loop/m-p/529389#M144633</guid>
      <dc:creator>robulon</dc:creator>
      <dc:date>2019-01-23T14:25:16Z</dc:date>
    </item>
    <item>
      <title>Re: Macro programming - use variable value for stop value in do loop</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-programming-use-variable-value-for-stop-value-in-do-loop/m-p/529396#M144637</link>
      <description>&lt;P&gt;Why do you have square brackets around the offset value in the INTNX function call?&lt;/P&gt;
&lt;P&gt;That is just going to cause trouble.&lt;/P&gt;
&lt;PRE&gt;666   data _null_;
667     x = mean([1],2,3);
                 -
                 22
ERROR: Undeclared array referenced: NAME.
ERROR: Variable NAME has not been declared as an array.
ERROR 22-322: Syntax error, expecting one of the following: a name, INPUT, PUT.

668   run;
&lt;/PRE&gt;</description>
      <pubDate>Wed, 23 Jan 2019 14:38:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-programming-use-variable-value-for-stop-value-in-do-loop/m-p/529396#M144637</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2019-01-23T14:38:09Z</dc:date>
    </item>
    <item>
      <title>Re: Macro programming - use variable value for stop value in do loop</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-programming-use-variable-value-for-stop-value-in-do-loop/m-p/529409#M144640</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159"&gt;@Tom&lt;/a&gt;&amp;nbsp;hit the nail on the head here.&amp;nbsp; Modify this statement:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT size="3"&gt;&lt;FONT face="Courier New"&gt;pdate[i] = intnx(&lt;/FONT&gt;&lt;FONT face="Courier New" color="#800080"&gt;'month'&lt;/FONT&gt;&lt;FONT face="Courier New"&gt;,promise_1_date2,[i],&lt;/FONT&gt;&lt;FONT face="Courier New" color="#800080"&gt;'same'&lt;/FONT&gt;&lt;FONT face="Courier New"&gt;);&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Remove the square brackets within the INTNX function (not anywhere else)::&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT size="3"&gt;&lt;FONT face="Courier New"&gt;pdate[i] = intnx(&lt;/FONT&gt;&lt;FONT face="Courier New" color="#800080"&gt;'month'&lt;/FONT&gt;&lt;FONT face="Courier New"&gt;,promise_1_date2, i ,&lt;/FONT&gt;&lt;FONT face="Courier New" color="#800080"&gt;'same'&lt;/FONT&gt;&lt;FONT face="Courier New"&gt;);&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And, of course, verify that the numbers that you get are correct.&lt;/P&gt;</description>
      <pubDate>Wed, 23 Jan 2019 15:09:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-programming-use-variable-value-for-stop-value-in-do-loop/m-p/529409#M144640</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2019-01-23T15:09:10Z</dc:date>
    </item>
    <item>
      <title>Re: Macro programming - use variable value for stop value in do loop</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-programming-use-variable-value-for-stop-value-in-do-loop/m-p/529418#M144646</link>
      <description>&lt;P&gt;Thanks both, really appreciate you taking the time to assist me.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Having taken the square brackets off the&amp;nbsp;i in the intnx statement, I'm now getting an error telling me the array subscript is out of range?&lt;/P&gt;</description>
      <pubDate>Wed, 23 Jan 2019 15:33:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-programming-use-variable-value-for-stop-value-in-do-loop/m-p/529418#M144646</guid>
      <dc:creator>robulon</dc:creator>
      <dc:date>2019-01-23T15:33:05Z</dc:date>
    </item>
    <item>
      <title>Re: Macro programming - use variable value for stop value in do loop</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-programming-use-variable-value-for-stop-value-in-do-loop/m-p/529419#M144647</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/62592"&gt;@robulon&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Thanks both, really appreciate you taking the time to assist me.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Having taken the square brackets off the&amp;nbsp;i in the intnx statement, I'm now getting an error telling me the array subscript is out of range?&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Why did you code DO I=1 to 12 when your arrays are defined with only 5 elements?&lt;/P&gt;
&lt;P&gt;What are you actually trying to do?&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Perhaps you really need two loops?&amp;nbsp; One over the variables and one over months?&lt;/P&gt;</description>
      <pubDate>Wed, 23 Jan 2019 15:35:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-programming-use-variable-value-for-stop-value-in-do-loop/m-p/529419#M144647</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2019-01-23T15:35:55Z</dc:date>
    </item>
    <item>
      <title>Re: Macro programming - use variable value for stop value in do loop</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-programming-use-variable-value-for-stop-value-in-do-loop/m-p/529433#M144658</link>
      <description>&lt;P&gt;Tom, the honest answer to your question is probably because I'm an idiot! I thought by saying do I = 8 - 12, it would only be populating 5 variables, hence my putting [5] in the array statement.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What I'm trying to do is depending on how many instalments there are for each specific observation, I want to populate that many of the date variables (so if there were 11 instalments, it would populate promise_1_date8 - promise_1_date11 and leave promise_1_date12 as a missing value).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;To calculate the value to go into each date variable, I want to add the corresponding number of months to promise_1_date2.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;It seemed straightforward in my head but is proving to be anything but (but I appreciate that is down to my SAS knowledge, or lack of!).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks again,&lt;/P&gt;&lt;P&gt;Rob&lt;/P&gt;</description>
      <pubDate>Wed, 23 Jan 2019 16:09:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-programming-use-variable-value-for-stop-value-in-do-loop/m-p/529433#M144658</guid>
      <dc:creator>robulon</dc:creator>
      <dc:date>2019-01-23T16:09:54Z</dc:date>
    </item>
    <item>
      <title>Re: Macro programming - use variable value for stop value in do loop</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-programming-use-variable-value-for-stop-value-in-do-loop/m-p/529438#M144661</link>
      <description>&lt;P&gt;Still not clear what you are trying to do.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Is it always 8 to 11?&amp;nbsp; &amp;nbsp;Does either number potentially change?&lt;/P&gt;
&lt;P&gt;Do you want to define a full series of variables, say from 1 to 12, but then only populate those from 8 to 11 with non-missing values?&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;array pdate  promise_date1 - promise_date12 ;
do month=8 to 11 ;
  pdate[month]= ....
end;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Or do you only want to define variables for this restricted range?&lt;/P&gt;
&lt;P&gt;Normally SAS will using indexes 1,2,3,4,.... for an array reference.&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;array pdate promise_date8 - promise_date11 ;
do month=8 to 11 ;
  pdate[month-7]= ....
end;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;But you can tell it to use a different range for the indexes.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;array pdate [8:11] promise_date8 - promise_date11 ;
do month=8 to 11 ;
  pdate[month]= ....
end;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 23 Jan 2019 16:27:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-programming-use-variable-value-for-stop-value-in-do-loop/m-p/529438#M144661</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2019-01-23T16:27:54Z</dc:date>
    </item>
    <item>
      <title>Re: Macro programming - use variable value for stop value in do loop</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-programming-use-variable-value-for-stop-value-in-do-loop/m-p/529465#M144670</link>
      <description>&lt;P&gt;My starting data set already has promise_1_dates and amounts from 1 to 7, but there is another variable (instalments) which is the total number of payments due, which can go up to 12. I am trying to create additional variables 8 to 12 where necessary and populate them with the dates each of those variables is due, and the due date will always be the same day of the month as promise_1_date_2 (but not necessarily the same as promise_1_date_1 as there may be an immediate payment with subsequent payments scheduled in on a monthly basis).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What I was trying to do was to create those additional variables and depending on the number of instalments for each observation, populate it with the requisite number of dates leaving any that aren't required as missing.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The amount due will always be the same regardless of when the instalment is due, and will always be the same as promise_1_amt_2.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Wed, 23 Jan 2019 17:48:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-programming-use-variable-value-for-stop-value-in-do-loop/m-p/529465#M144670</guid>
      <dc:creator>robulon</dc:creator>
      <dc:date>2019-01-23T17:48:43Z</dc:date>
    </item>
    <item>
      <title>Re: Macro programming - use variable value for stop value in do loop</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-programming-use-variable-value-for-stop-value-in-do-loop/m-p/529466#M144671</link>
      <description>&lt;P&gt;And sorry, to clarify, the number in the date variable name does not necessarily correspond to calendar months (so promise_1_date8 is not necessarily in August), it is purely the number of months after the arrangement is set (which is stored in a separate variable).&lt;/P&gt;</description>
      <pubDate>Wed, 23 Jan 2019 17:50:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-programming-use-variable-value-for-stop-value-in-do-loop/m-p/529466#M144671</guid>
      <dc:creator>robulon</dc:creator>
      <dc:date>2019-01-23T17:50:47Z</dc:date>
    </item>
    <item>
      <title>Re: Macro programming - use variable value for stop value in do loop</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-programming-use-variable-value-for-stop-value-in-do-loop/m-p/529471#M144674</link>
      <description>&lt;P&gt;So just make the arrays include all of the variables. Then your indexes will work.&amp;nbsp; Note that there is no need to tell SAS how many variables there are in the array when you have listed their names.&amp;nbsp; It can count.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test_2;
  set prom_201812;
  array pdate promise_1_date1 - promise_1_date12;
  array pamt  promise_1_amt1 - promise_1_amt12;
  if instalments &amp;gt; 7 then do i = 8 to 12;
    pdate[i] = intnx('month',pdate[2],i,'same');
    pamt[i] = pamt[2];
  end;
  format promise_1_date1 - promise_1_date12 ddmmyy10.;
  drop i;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Personally I wouldn't use DDMMYY format. It will confuse half of your users.&amp;nbsp; If you use DATE or YYMMDD then nobody will confuse Dec 10th with Oct 12th.&lt;/P&gt;</description>
      <pubDate>Wed, 23 Jan 2019 18:06:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-programming-use-variable-value-for-stop-value-in-do-loop/m-p/529471#M144674</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2019-01-23T18:06:38Z</dc:date>
    </item>
    <item>
      <title>Re: Macro programming - use variable value for stop value in do loop</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-programming-use-variable-value-for-stop-value-in-do-loop/m-p/529574#M144715</link>
      <description>&lt;P&gt;This solution appears to be most of the way there.&amp;nbsp; This statement looks incorrect:&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 keyword"&gt;if&lt;/SPAN&gt; instalments &lt;SPAN class="token operator"&gt;&amp;gt;&lt;/SPAN&gt; &lt;SPAN class="token number"&gt;7&lt;/SPAN&gt; &lt;SPAN class="token keyword"&gt;then&lt;/SPAN&gt; do i &lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt; &lt;SPAN class="token number"&gt;8&lt;/SPAN&gt; to &lt;FONT color="#FF0000"&gt;&lt;SPAN class="token number"&gt;12&lt;/SPAN&gt;&lt;/FONT&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I think you were looking for this instead:&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 keyword"&gt;if&lt;/SPAN&gt; instalments &lt;SPAN class="token operator"&gt;&amp;gt;&lt;/SPAN&gt; &lt;SPAN class="token number"&gt;7&lt;/SPAN&gt; &lt;SPAN class="token keyword"&gt;then&lt;/SPAN&gt; do i &lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt; &lt;SPAN class="token number"&gt;8&lt;/SPAN&gt; to &lt;FONT color="#FF0000"&gt;instalments&lt;/FONT&gt;;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 23 Jan 2019 22:20:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-programming-use-variable-value-for-stop-value-in-do-loop/m-p/529574#M144715</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2019-01-23T22:20:55Z</dc:date>
    </item>
    <item>
      <title>Re: Macro programming - use variable value for stop value in do loop</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-programming-use-variable-value-for-stop-value-in-do-loop/m-p/529635#M144743</link>
      <description>&lt;P&gt;Thank you both so much, this is working perfectly and I have learnt a bit more about the use of arrays as well!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Tom, the existing dates in the dataset are already in the ddmmyy format, and being in the UK, this is generally how we do dates anyway but thanks for the pointer. Certainly if this was going to an international audience, it wold be something to bear in mind.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;All the best,&lt;/P&gt;&lt;P&gt;Rob&lt;/P&gt;</description>
      <pubDate>Thu, 24 Jan 2019 08:56:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-programming-use-variable-value-for-stop-value-in-do-loop/m-p/529635#M144743</guid>
      <dc:creator>robulon</dc:creator>
      <dc:date>2019-01-24T08:56:28Z</dc:date>
    </item>
  </channel>
</rss>

