<?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: Output statement error in macro with %do %until in SAS Studio</title>
    <link>https://communities.sas.com/t5/SAS-Studio/Output-statement-error-in-macro-with-do-until/m-p/463775#M5553</link>
    <description>&lt;P&gt;Thanks for responding.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I noticed two things. First is that the %do %until was the problem. When I replaced it by the&amp;nbsp;%do i=1 %to (&amp;amp;theperiod.*12) ; then the code compiled successfully and produced the expected result.&lt;/P&gt;&lt;P&gt;The second thing that made it work is by removing the % sign from the if&amp;nbsp; then.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Can someone explain to me why especially for the case of the %do %until which did not work?&lt;/P&gt;&lt;P&gt;Thanks.&lt;/P&gt;</description>
    <pubDate>Mon, 21 May 2018 13:35:33 GMT</pubDate>
    <dc:creator>setod003</dc:creator>
    <dc:date>2018-05-21T13:35:33Z</dc:date>
    <item>
      <title>Output statement error in macro with %do %until</title>
      <link>https://communities.sas.com/t5/SAS-Studio/Output-statement-error-in-macro-with-do-until/m-p/462859#M5535</link>
      <description>&lt;P&gt;I wrote this SAS amortization schedule program. First without macro the program compiles fine. Please see code below:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data amortzAB;


	balance=480000;
	
		month=0;
		do until (month&amp;gt;=30*12);
			
		
			        month=month+1;
			 /*Compute interest rate amortized;*/
				rate= 0.06/12  ;  
			/*Compute the monthly payment;*/
				monthly =(480000)*(rate*(1+rate)**(30*12))/((1+rate)**(30*12)-1);
			/*Compute interest paid every month;*/
				interest_amount=(balance)*rate;
			/*Compute principal toward amount borrowed;*/
				principal_toward_paymt=monthly-interest_amount;
			/*Updated the new balance after each month;*/
				balance=(balance)-principal_toward_paymt;
				
					
			if (balance&amp;lt;monthly) then monthly=balance;
	
			if (balance &amp;lt;0) then stop;
				
				 
			output;
				
				    		
			  
			 
		END;
 		
run;

proc print data=amortzAB; 
var balance rate monthly  principal_toward_paymt interest_amount month ;
title "Amortization schedule  &amp;amp;theplan. with &amp;amp;theperiod. years";
title2 "and a downpayment of &amp;amp;thedeposit.";
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Now I turned over to the use of macro but I keep getting this error :&lt;/P&gt;&lt;DIV class="sasNote"&gt;NOTE: Line generated by the invoked macro "AMORTZ_MACRO".&lt;/DIV&gt;&lt;DIV class="sasSource"&gt;126 output;&lt;/DIV&gt;&lt;DIV class="sasError"&gt;______&lt;/DIV&gt;&lt;DIV class="sasError"&gt;22&lt;/DIV&gt;&lt;DIV class="sasSource"&gt;SYMBOLGEN: Macro variable THEPERIOD resolves to 15&lt;/DIV&gt;&lt;DIV class="sasSource"&gt;MLOGIC(AMORTZ_MACRO): %DO %UNTIL() condition is TRUE; loop will not iterate again.&lt;/DIV&gt;&lt;DIV class="sasSource"&gt;MPRINT(AMORTZ_MACRO): monthly=balance output;&lt;/DIV&gt;&lt;DIV class="sasSource"&gt;MPRINT(AMORTZ_MACRO): run;&lt;/DIV&gt;&lt;DIV class="sasNote"&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV class="sasError"&gt;ERROR 22-322: Syntax error, expecting one of the following: !, !!, &amp;amp;, *, **, +, -, /, ;, &amp;lt;, &amp;lt;=, &amp;lt;&amp;gt;, =, &amp;gt;, &amp;gt;&amp;lt;, &amp;gt;=, AND, EQ, GE, GT,&lt;/DIV&gt;&lt;DIV class="sasError"&gt;IN, LE, LT, MAX, MIN, NE, NG, NL, NOTIN, OR, ^=, |, ||, ~=.&lt;/DIV&gt;&lt;DIV class="sasError"&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV class="sasError"&gt;Please see code below.&lt;/DIV&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;OPTIONS MPRINT MLOGIC SYMBOLGEN;


%macro amortz_macro (theplan=,thebalance=,therate=, theperiod=, thedeposit=);


data amortzAB;

	
	balance=&amp;amp;thebalance.;
	
		month=0;
		%do %until (month&amp;gt;=&amp;amp;theperiod.*12);
			
		
			        month=month+1;
			 /*Compute interest rate amortized;*/
				rate= &amp;amp;therate./12  ;  
			/*Compute the monthly payment;*/
				monthly =(&amp;amp;thebalance.)*(rate*(1+rate)**(&amp;amp;theperiod.*12))/((1+rate)**(&amp;amp;theperiod.*12)-1);
			/*Compute interest paid every month;*/
				interest_amount=(balance)*rate;
			/*Compute principal toward amount borrowed;*/
				principal_toward_paymt=monthly-interest_amount;
			/*Updated the new balance after each month;*/
				balance=(balance)-principal_toward_paymt;
				
					
			%if (balance&amp;lt;monthly) %then monthly=balance;
	
			%if (balance &amp;lt;0) %then stop;
				
			output;
				    		
			  
			 
		%END;
		
		
 		
run;

proc print data=amortzAB; 
var balance rate monthly  principal_toward_paymt interest_amount month ;
title "Amortization schedule  &amp;amp;theplan. with &amp;amp;theperiod. years";
title2 "and a downpayment of &amp;amp;thedeposit.";
run;


%mend amortz_macro;

%amortz_macro(theplan=A,thebalance=480000,therate=0.06, theperiod=30, thedeposit=120000);
%amortz_macro(theplan=B,thebalance=499200,therate=0.055, theperiod=30, thedeposit=120000);
%amortz_macro(theplan=A,thebalance=480000,therate=0.06, theperiod=15, thedeposit=120000);&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Can anybody help determine what is the real problem.-Thanks.&lt;/P&gt;</description>
      <pubDate>Wed, 16 May 2018 21:15:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/Output-statement-error-in-macro-with-do-until/m-p/462859#M5535</guid>
      <dc:creator>setod003</dc:creator>
      <dc:date>2018-05-16T21:15:21Z</dc:date>
    </item>
    <item>
      <title>Re: Output statement error in macro with %do %until</title>
      <link>https://communities.sas.com/t5/SAS-Studio/Output-statement-error-in-macro-with-do-until/m-p/462865#M5536</link>
      <description>&lt;P&gt;Just because you are writing a macro doesn't mean you have to switch to %IF and %DO.&amp;nbsp; Get rid of all the percent signs and you should be fine (keep the ampersands, however).&lt;/P&gt;</description>
      <pubDate>Wed, 16 May 2018 21:21:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/Output-statement-error-in-macro-with-do-until/m-p/462865#M5536</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2018-05-16T21:21:42Z</dc:date>
    </item>
    <item>
      <title>Re: Output statement error in macro with %do %until</title>
      <link>https://communities.sas.com/t5/SAS-Studio/Output-statement-error-in-macro-with-do-until/m-p/462870#M5537</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/4954"&gt;@Astounding&lt;/a&gt;&amp;nbsp;Simply &lt;STRONG&gt;Brilliant!!!!!!&lt;/STRONG&gt; line&lt;/P&gt;</description>
      <pubDate>Wed, 16 May 2018 21:23:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/Output-statement-error-in-macro-with-do-until/m-p/462870#M5537</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2018-05-16T21:23:32Z</dc:date>
    </item>
    <item>
      <title>Re: Output statement error in macro with %do %until</title>
      <link>https://communities.sas.com/t5/SAS-Studio/Output-statement-error-in-macro-with-do-until/m-p/463775#M5553</link>
      <description>&lt;P&gt;Thanks for responding.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I noticed two things. First is that the %do %until was the problem. When I replaced it by the&amp;nbsp;%do i=1 %to (&amp;amp;theperiod.*12) ; then the code compiled successfully and produced the expected result.&lt;/P&gt;&lt;P&gt;The second thing that made it work is by removing the % sign from the if&amp;nbsp; then.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Can someone explain to me why especially for the case of the %do %until which did not work?&lt;/P&gt;&lt;P&gt;Thanks.&lt;/P&gt;</description>
      <pubDate>Mon, 21 May 2018 13:35:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/Output-statement-error-in-macro-with-do-until/m-p/463775#M5553</guid>
      <dc:creator>setod003</dc:creator>
      <dc:date>2018-05-21T13:35:33Z</dc:date>
    </item>
  </channel>
</rss>

