<?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: %do %to macro doenst stop after match a condition in SAS Enterprise Guide</title>
    <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/do-to-macro-doenst-stop-after-match-a-condition/m-p/734184#M38549</link>
    <description>&lt;P&gt;Please follow the instructions I gave for preserving the formatting of the log.&lt;/P&gt;</description>
    <pubDate>Thu, 15 Apr 2021 10:53:34 GMT</pubDate>
    <dc:creator>PaigeMiller</dc:creator>
    <dc:date>2021-04-15T10:53:34Z</dc:date>
    <item>
      <title>%do %to macro doenst stop after match a condition</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/do-to-macro-doenst-stop-after-match-a-condition/m-p/733913#M38543</link>
      <description>&lt;P&gt;hi there!&lt;BR /&gt;I've a problem within my macro:&lt;BR /&gt;My data has 200k+ lines and my itention is:&lt;BR /&gt;When my looping variable is greater then&lt;BR /&gt;my variable QT_PARCELA (numeric type per lina) all my values in colluns after that should be 0, however my macro doens't stop when the variable DU is greater then QT_PARCELA, anyone can help me pls? &lt;span class="lia-unicode-emoji" title=":grinning_face_with_smiling_eyes:"&gt;😄&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;%MACRO LOOP();&lt;BR /&gt;DATA TESTE;&lt;BR /&gt;SET BASE_INFO_EXP2;&lt;BR /&gt;%DO DU=0 %TO 6;&lt;BR /&gt;%IF &amp;amp;DU. LE QT_PARCELA %THEN %DO;&lt;BR /&gt;%IF &amp;amp;DU. EQ 0 %THEN %DO;&lt;BR /&gt;RISCO_M&amp;amp;DU. = VL_PRODUCAO;&lt;BR /&gt;JUROS_M&amp;amp;DU. = 0;&lt;BR /&gt;AMORT_M&amp;amp;DU. = 0;&lt;BR /&gt;%END;&lt;BR /&gt;%ELSE %DO;&lt;BR /&gt;%LET DU_AUX = %SYSFUNC(SUM(&amp;amp;DU. -1));&lt;BR /&gt;JUROS_M&amp;amp;DU. = RISCO_M&amp;amp;DU_AUX. * (TAXA / 100);&lt;BR /&gt;AMORT_M&amp;amp;DU. = VL_PARCELA - JUROS_M&amp;amp;DU.;&lt;BR /&gt;RISCO_M&amp;amp;DU. = RISCO_M&amp;amp;DU_AUX. - AMORT_M&amp;amp;DU.;&lt;BR /&gt;%END;&lt;BR /&gt;%END;&lt;BR /&gt;%ELSE %DO;&lt;BR /&gt;JUROS_M&amp;amp;DU. = 0;&lt;BR /&gt;AMORT_M&amp;amp;DU. = 0;&lt;BR /&gt;RISCO_M&amp;amp;DU. = 0;&lt;BR /&gt;%END;&lt;BR /&gt;%END;&lt;BR /&gt;RUN;&lt;BR /&gt;%MEND;&lt;/P&gt;&lt;P&gt;%LOOP();&lt;/P&gt;</description>
      <pubDate>Wed, 14 Apr 2021 20:29:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/do-to-macro-doenst-stop-after-match-a-condition/m-p/733913#M38543</guid>
      <dc:creator>erickdt</dc:creator>
      <dc:date>2021-04-14T20:29:59Z</dc:date>
    </item>
    <item>
      <title>Re: %do %to macro doenst stop after match a condition</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/do-to-macro-doenst-stop-after-match-a-condition/m-p/733915#M38544</link>
      <description>&lt;P&gt;First, you can help yourself by indenting your code properly so it is much easier to see where each %DO statement begins and ends.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Second, you can help yourself by using ARRAY statements in DATA steps, rather than macro loops. These are easier to construct as they rely entirely on DATA step commands, and also easier to debug.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Next, if you still have to write this a macro (which I am skeptical of) you can also help yourself by turning on diagnostics, via this command, and then running your code again.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;options mprint mlogic symbolgen;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;This writes diagnostic information to the LOG to help you debug the code. So please take a look at what is in the LOG to see if you can figure out what the problem is. If you still need help, show us the LOG from running this macro, all of it, 100%, nothing left out, every single character, not selected parts. Please copy the log as text and then paste it into the window that appears when you click on the &amp;lt;/&amp;gt; icon. This preserves the formatting of the LOG and makes it easier to read ... some of us will not even try to read logs if you do not follow these instructions and preserve the formatting of the LOG.&lt;/P&gt;</description>
      <pubDate>Wed, 14 Apr 2021 20:44:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/do-to-macro-doenst-stop-after-match-a-condition/m-p/733915#M38544</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2021-04-14T20:44:12Z</dc:date>
    </item>
    <item>
      <title>Re: %do %to macro doenst stop after match a condition</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/do-to-macro-doenst-stop-after-match-a-condition/m-p/733919#M38545</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/10892"&gt;@PaigeMiller&lt;/a&gt;&amp;nbsp; i've made identing, however when I use Crtl.c + cltr.v its lost... that is not my fault &lt;span class="lia-unicode-emoji" title=":disappointed_face:"&gt;😞&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;follow my log:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;24 GOPTIONS ACCESSIBLE;&lt;BR /&gt;25&lt;BR /&gt;26 options mprint mlogic symbolgen;&lt;BR /&gt;27 %MACRO LOOP();&lt;BR /&gt;28 %MACRO X();&lt;BR /&gt;29 %MEND X;&lt;BR /&gt;30 DATA TESTE;&lt;BR /&gt;31 SET BASE_INFO_EXP2;&lt;BR /&gt;32 %DO DU=0 %TO 6;&lt;BR /&gt;33 %IF &amp;amp;DU. LE QT_PARCELA %THEN %DO;&lt;BR /&gt;34 %IF &amp;amp;DU. EQ 0 %THEN %DO;&lt;BR /&gt;35 RISCO_M&amp;amp;DU. = VL_PRODUCAO;&lt;BR /&gt;36 JUROS_M&amp;amp;DU. = 0;&lt;BR /&gt;37 AMORT_M&amp;amp;DU. = 0;&lt;BR /&gt;38 %END;&lt;BR /&gt;39 %ELSE %DO;&lt;BR /&gt;40 %LET DU_AUX = %SYSFUNC(SUM(&amp;amp;DU. -1));&lt;BR /&gt;41 JUROS_M&amp;amp;DU. = RISCO_M&amp;amp;DU_AUX. * (TAXA / 100);&lt;BR /&gt;42 AMORT_M&amp;amp;DU. = VL_PARCELA - JUROS_M&amp;amp;DU.;&lt;BR /&gt;43 RISCO_M&amp;amp;DU. = RISCO_M&amp;amp;DU_AUX. - AMORT_M&amp;amp;DU.;&lt;BR /&gt;44 %END;&lt;BR /&gt;45 %END;&lt;BR /&gt;46 %ELSE %DO;&lt;BR /&gt;47 JUROS_M&amp;amp;DU. = 0;&lt;BR /&gt;48 AMORT_M&amp;amp;DU. = 0;&lt;BR /&gt;49 RISCO_M&amp;amp;DU. = 0;&lt;BR /&gt;50 %END;&lt;BR /&gt;51 %END;&lt;BR /&gt;52 RUN;&lt;BR /&gt;53 %MEND;&lt;BR /&gt;2 The SAS System 14:22 Wednesday, April 14, 2021&lt;/P&gt;&lt;P&gt;54&lt;BR /&gt;55 %LOOP();&lt;BR /&gt;MLOGIC(LOOP): Beginning execution.&lt;BR /&gt;MPRINT(LOOP): DATA TESTE;&lt;BR /&gt;MPRINT(LOOP): SET BASE_INFO_EXP2;&lt;BR /&gt;MLOGIC(LOOP): %DO loop beginning; index variable DU; start value is 0; stop value is 6; by value is 1.&lt;BR /&gt;SYMBOLGEN: Macro variable DU resolves to 0&lt;BR /&gt;MLOGIC(LOOP): %IF condition &amp;amp;DU. LE QT_PARCELA is TRUE&lt;BR /&gt;SYMBOLGEN: Macro variable DU resolves to 0&lt;BR /&gt;MLOGIC(LOOP): %IF condition &amp;amp;DU. EQ 0 is TRUE&lt;BR /&gt;SYMBOLGEN: Macro variable DU resolves to 0&lt;BR /&gt;MPRINT(LOOP): RISCO_M0 = VL_PRODUCAO;&lt;BR /&gt;SYMBOLGEN: Macro variable DU resolves to 0&lt;BR /&gt;MPRINT(LOOP): JUROS_M0 = 0;&lt;BR /&gt;SYMBOLGEN: Macro variable DU resolves to 0&lt;BR /&gt;MPRINT(LOOP): AMORT_M0 = 0;&lt;BR /&gt;MLOGIC(LOOP): %DO loop index variable DU is now 1; loop will iterate again.&lt;BR /&gt;SYMBOLGEN: Macro variable DU resolves to 1&lt;BR /&gt;MLOGIC(LOOP): %IF condition &amp;amp;DU. LE QT_PARCELA is TRUE&lt;BR /&gt;SYMBOLGEN: Macro variable DU resolves to 1&lt;BR /&gt;MLOGIC(LOOP): %IF condition &amp;amp;DU. EQ 0 is FALSE&lt;BR /&gt;MLOGIC(LOOP): %LET (variable name is DU_AUX)&lt;BR /&gt;SYMBOLGEN: Macro variable DU resolves to 1&lt;BR /&gt;SYMBOLGEN: Macro variable DU resolves to 1&lt;BR /&gt;SYMBOLGEN: Macro variable DU_AUX resolves to 0&lt;BR /&gt;MPRINT(LOOP): JUROS_M1 = RISCO_M0 * (TAXA / 100);&lt;BR /&gt;SYMBOLGEN: Macro variable DU resolves to 1&lt;BR /&gt;SYMBOLGEN: Macro variable DU resolves to 1&lt;BR /&gt;MPRINT(LOOP): AMORT_M1 = VL_PARCELA - JUROS_M1;&lt;BR /&gt;SYMBOLGEN: Macro variable DU resolves to 1&lt;BR /&gt;SYMBOLGEN: Macro variable DU_AUX resolves to 0&lt;BR /&gt;SYMBOLGEN: Macro variable DU resolves to 1&lt;BR /&gt;MPRINT(LOOP): RISCO_M1 = RISCO_M0 - AMORT_M1;&lt;BR /&gt;MLOGIC(LOOP): %DO loop index variable DU is now 2; loop will iterate again.&lt;BR /&gt;SYMBOLGEN: Macro variable DU resolves to 2&lt;BR /&gt;MLOGIC(LOOP): %IF condition &amp;amp;DU. LE QT_PARCELA is TRUE&lt;BR /&gt;SYMBOLGEN: Macro variable DU resolves to 2&lt;BR /&gt;MLOGIC(LOOP): %IF condition &amp;amp;DU. EQ 0 is FALSE&lt;BR /&gt;MLOGIC(LOOP): %LET (variable name is DU_AUX)&lt;BR /&gt;SYMBOLGEN: Macro variable DU resolves to 2&lt;BR /&gt;SYMBOLGEN: Macro variable DU resolves to 2&lt;BR /&gt;SYMBOLGEN: Macro variable DU_AUX resolves to 1&lt;BR /&gt;MPRINT(LOOP): JUROS_M2 = RISCO_M1 * (TAXA / 100);&lt;BR /&gt;SYMBOLGEN: Macro variable DU resolves to 2&lt;BR /&gt;SYMBOLGEN: Macro variable DU resolves to 2&lt;BR /&gt;MPRINT(LOOP): AMORT_M2 = VL_PARCELA - JUROS_M2;&lt;BR /&gt;SYMBOLGEN: Macro variable DU resolves to 2&lt;BR /&gt;SYMBOLGEN: Macro variable DU_AUX resolves to 1&lt;BR /&gt;SYMBOLGEN: Macro variable DU resolves to 2&lt;BR /&gt;MPRINT(LOOP): RISCO_M2 = RISCO_M1 - AMORT_M2;&lt;BR /&gt;MLOGIC(LOOP): %DO loop index variable DU is now 3; loop will iterate again.&lt;BR /&gt;SYMBOLGEN: Macro variable DU resolves to 3&lt;BR /&gt;MLOGIC(LOOP): %IF condition &amp;amp;DU. LE QT_PARCELA is TRUE&lt;BR /&gt;SYMBOLGEN: Macro variable DU resolves to 3&lt;BR /&gt;MLOGIC(LOOP): %IF condition &amp;amp;DU. EQ 0 is FALSE&lt;BR /&gt;MLOGIC(LOOP): %LET (variable name is DU_AUX)&lt;BR /&gt;SYMBOLGEN: Macro variable DU resolves to 3&lt;BR /&gt;SYMBOLGEN: Macro variable DU resolves to 3&lt;BR /&gt;3 The SAS System 14:22 Wednesday, April 14, 2021&lt;/P&gt;&lt;P&gt;SYMBOLGEN: Macro variable DU_AUX resolves to 2&lt;BR /&gt;MPRINT(LOOP): JUROS_M3 = RISCO_M2 * (TAXA / 100);&lt;BR /&gt;SYMBOLGEN: Macro variable DU resolves to 3&lt;BR /&gt;SYMBOLGEN: Macro variable DU resolves to 3&lt;BR /&gt;MPRINT(LOOP): AMORT_M3 = VL_PARCELA - JUROS_M3;&lt;BR /&gt;SYMBOLGEN: Macro variable DU resolves to 3&lt;BR /&gt;SYMBOLGEN: Macro variable DU_AUX resolves to 2&lt;BR /&gt;SYMBOLGEN: Macro variable DU resolves to 3&lt;BR /&gt;MPRINT(LOOP): RISCO_M3 = RISCO_M2 - AMORT_M3;&lt;BR /&gt;MLOGIC(LOOP): %DO loop index variable DU is now 4; loop will iterate again.&lt;BR /&gt;SYMBOLGEN: Macro variable DU resolves to 4&lt;BR /&gt;MLOGIC(LOOP): %IF condition &amp;amp;DU. LE QT_PARCELA is TRUE&lt;BR /&gt;SYMBOLGEN: Macro variable DU resolves to 4&lt;BR /&gt;MLOGIC(LOOP): %IF condition &amp;amp;DU. EQ 0 is FALSE&lt;BR /&gt;MLOGIC(LOOP): %LET (variable name is DU_AUX)&lt;BR /&gt;SYMBOLGEN: Macro variable DU resolves to 4&lt;BR /&gt;SYMBOLGEN: Macro variable DU resolves to 4&lt;BR /&gt;SYMBOLGEN: Macro variable DU_AUX resolves to 3&lt;BR /&gt;MPRINT(LOOP): JUROS_M4 = RISCO_M3 * (TAXA / 100);&lt;BR /&gt;SYMBOLGEN: Macro variable DU resolves to 4&lt;BR /&gt;SYMBOLGEN: Macro variable DU resolves to 4&lt;BR /&gt;MPRINT(LOOP): AMORT_M4 = VL_PARCELA - JUROS_M4;&lt;BR /&gt;SYMBOLGEN: Macro variable DU resolves to 4&lt;BR /&gt;SYMBOLGEN: Macro variable DU_AUX resolves to 3&lt;BR /&gt;SYMBOLGEN: Macro variable DU resolves to 4&lt;BR /&gt;MPRINT(LOOP): RISCO_M4 = RISCO_M3 - AMORT_M4;&lt;BR /&gt;MLOGIC(LOOP): %DO loop index variable DU is now 5; loop will iterate again.&lt;BR /&gt;SYMBOLGEN: Macro variable DU resolves to 5&lt;BR /&gt;MLOGIC(LOOP): %IF condition &amp;amp;DU. LE QT_PARCELA is TRUE&lt;BR /&gt;SYMBOLGEN: Macro variable DU resolves to 5&lt;BR /&gt;MLOGIC(LOOP): %IF condition &amp;amp;DU. EQ 0 is FALSE&lt;BR /&gt;MLOGIC(LOOP): %LET (variable name is DU_AUX)&lt;BR /&gt;SYMBOLGEN: Macro variable DU resolves to 5&lt;BR /&gt;SYMBOLGEN: Macro variable DU resolves to 5&lt;BR /&gt;SYMBOLGEN: Macro variable DU_AUX resolves to 4&lt;BR /&gt;MPRINT(LOOP): JUROS_M5 = RISCO_M4 * (TAXA / 100);&lt;BR /&gt;SYMBOLGEN: Macro variable DU resolves to 5&lt;BR /&gt;SYMBOLGEN: Macro variable DU resolves to 5&lt;BR /&gt;MPRINT(LOOP): AMORT_M5 = VL_PARCELA - JUROS_M5;&lt;BR /&gt;SYMBOLGEN: Macro variable DU resolves to 5&lt;BR /&gt;SYMBOLGEN: Macro variable DU_AUX resolves to 4&lt;BR /&gt;SYMBOLGEN: Macro variable DU resolves to 5&lt;BR /&gt;MPRINT(LOOP): RISCO_M5 = RISCO_M4 - AMORT_M5;&lt;BR /&gt;MLOGIC(LOOP): %DO loop index variable DU is now 6; loop will iterate again.&lt;BR /&gt;SYMBOLGEN: Macro variable DU resolves to 6&lt;BR /&gt;MLOGIC(LOOP): %IF condition &amp;amp;DU. LE QT_PARCELA is TRUE&lt;BR /&gt;SYMBOLGEN: Macro variable DU resolves to 6&lt;BR /&gt;MLOGIC(LOOP): %IF condition &amp;amp;DU. EQ 0 is FALSE&lt;BR /&gt;MLOGIC(LOOP): %LET (variable name is DU_AUX)&lt;BR /&gt;SYMBOLGEN: Macro variable DU resolves to 6&lt;BR /&gt;SYMBOLGEN: Macro variable DU resolves to 6&lt;BR /&gt;SYMBOLGEN: Macro variable DU_AUX resolves to 5&lt;BR /&gt;MPRINT(LOOP): JUROS_M6 = RISCO_M5 * (TAXA / 100);&lt;BR /&gt;SYMBOLGEN: Macro variable DU resolves to 6&lt;BR /&gt;SYMBOLGEN: Macro variable DU resolves to 6&lt;BR /&gt;MPRINT(LOOP): AMORT_M6 = VL_PARCELA - JUROS_M6;&lt;BR /&gt;SYMBOLGEN: Macro variable DU resolves to 6&lt;BR /&gt;SYMBOLGEN: Macro variable DU_AUX resolves to 5&lt;BR /&gt;4 The SAS System 14:22 Wednesday, April 14, 2021&lt;/P&gt;&lt;P&gt;SYMBOLGEN: Macro variable DU resolves to 6&lt;BR /&gt;MPRINT(LOOP): RISCO_M6 = RISCO_M5 - AMORT_M6;&lt;BR /&gt;MLOGIC(LOOP): %DO loop index variable DU is now 7; loop will not iterate again.&lt;BR /&gt;MPRINT(LOOP): RUN;&lt;/P&gt;&lt;P&gt;NOTE: There were 213295 observations read from the data set WORK.BASE_INFO_EXP2.&lt;BR /&gt;NOTE: The data set WORK.TESTE has 213295 observations and 48 variables.&lt;BR /&gt;NOTE: Compressing data set WORK.TESTE decreased size by 53.15 percent.&lt;BR /&gt;Compressed is 1234 pages; un-compressed would require 2634 pages.&lt;BR /&gt;NOTE: DATA statement used (Total process time):&lt;BR /&gt;real time 2.02 seconds&lt;BR /&gt;user cpu time 1.60 seconds&lt;BR /&gt;system cpu time 0.13 seconds&lt;BR /&gt;memory 699.00k&lt;BR /&gt;OS Memory 26020.00k&lt;BR /&gt;Timestamp 04/14/2021 05:45:06 PM&lt;BR /&gt;Step Count 94 Switch Count 37&lt;BR /&gt;Page Faults 0&lt;BR /&gt;Page Reclaims 994&lt;BR /&gt;Page Swaps 0&lt;BR /&gt;Voluntary Context Switches 1423&lt;BR /&gt;Involuntary Context Switches 123&lt;BR /&gt;Block Input Operations 984&lt;BR /&gt;Block Output Operations 157984&lt;/P&gt;&lt;P&gt;MLOGIC(LOOP): Ending execution.&lt;BR /&gt;56&lt;BR /&gt;57&lt;BR /&gt;58 GOPTIONS NOACCESSIBLE;&lt;BR /&gt;59 %LET _CLIENTTASKLABEL=;&lt;BR /&gt;60 %LET _CLIENTPROCESSFLOWNAME=;&lt;BR /&gt;61 %LET _CLIENTPROJECTPATH=;&lt;BR /&gt;62 %LET _CLIENTPROJECTPATHHOST=;&lt;BR /&gt;63 %LET _CLIENTPROJECTNAME=;&lt;BR /&gt;64 %LET _SASPROGRAMFILE=;&lt;BR /&gt;65 %LET _SASPROGRAMFILEHOST=;&lt;BR /&gt;66&lt;BR /&gt;67 ;*';*";*/;quit;run;&lt;BR /&gt;68 ODS _ALL_ CLOSE;&lt;BR /&gt;69&lt;BR /&gt;70&lt;BR /&gt;71 QUIT; RUN;&lt;BR /&gt;72&lt;/P&gt;</description>
      <pubDate>Wed, 14 Apr 2021 20:50:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/do-to-macro-doenst-stop-after-match-a-condition/m-p/733919#M38545</guid>
      <dc:creator>erickdt</dc:creator>
      <dc:date>2021-04-14T20:50:24Z</dc:date>
    </item>
    <item>
      <title>Re: %do %to macro doenst stop after match a condition</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/do-to-macro-doenst-stop-after-match-a-condition/m-p/733966#M38546</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/278427"&gt;@erickdt&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/10892"&gt;@PaigeMiller&lt;/a&gt;&amp;nbsp; i've made identing, however when I use Crtl.c + cltr.v its lost... that is not my fault &lt;span class="lia-unicode-emoji" title=":disappointed_face:"&gt;😞&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;No it isn't your fault, it a by product of the forum. To prevent your text from getting reformatted you need to open a text box by clicking on the &amp;lt;/&amp;gt; icon above the message window and the paste into that window. Which will look like:&lt;/P&gt;
&lt;PRE&gt;data junk;
   set sashelp.class;
run;&lt;/PRE&gt;
&lt;P&gt;If you want color highlighted code you could open a code box by clicking on the little "running man" icon to open a different box, and then paste.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;None of the Macro %if comparisons ever see the value of your data step variables. Macro code is compiled and implemented before the data step executes.&lt;/P&gt;
&lt;P&gt;When this is encountered&lt;/P&gt;
&lt;P&gt;33 %IF &amp;amp;DU. LE QT_PARCELA %THEN %DO;&lt;/P&gt;
&lt;P&gt;the macro variable &amp;amp;du is compared to the literal text QT_PARCELA, not the value of the variable in the data set that you likely intend. So the above is never true and the text of the code&lt;/P&gt;
&lt;PRE&gt;RISCO_M&amp;amp;DU. = VL_PRODUCAO;
JUROS_M&amp;amp;DU. = 0;
AMORT_M&amp;amp;DU. = 0;&lt;/PRE&gt;
&lt;P&gt;is not created for the data step.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Repeat: Macro %if does not see the value of variables in a data step.&lt;/P&gt;</description>
      <pubDate>Wed, 14 Apr 2021 21:40:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/do-to-macro-doenst-stop-after-match-a-condition/m-p/733966#M38546</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2021-04-14T21:40:52Z</dc:date>
    </item>
    <item>
      <title>Re: %do %to macro doenst stop after match a condition</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/do-to-macro-doenst-stop-after-match-a-condition/m-p/734184#M38549</link>
      <description>&lt;P&gt;Please follow the instructions I gave for preserving the formatting of the log.&lt;/P&gt;</description>
      <pubDate>Thu, 15 Apr 2021 10:53:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/do-to-macro-doenst-stop-after-match-a-condition/m-p/734184#M38549</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2021-04-15T10:53:34Z</dc:date>
    </item>
    <item>
      <title>Re: %do %to macro doenst stop after match a condition</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/do-to-macro-doenst-stop-after-match-a-condition/m-p/734197#M38551</link>
      <description>&lt;P&gt;Use this button for posting logs:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Bildschirmfoto 2020-04-07 um 08.32.59.jpg" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/54552i914D97BE1B0F21E5/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Bildschirmfoto 2020-04-07 um 08.32.59.jpg" alt="Bildschirmfoto 2020-04-07 um 08.32.59.jpg" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;Use the "little running man" right next to it for SAS code, it mimics the coloring of the Enhanced Editor.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Don't shout at the SAS interpreter, code is much easier to read if not written in all uppercase.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Maxim 12: use indentation to identify code blocks, spaghetti code will only cause yourself (and others who have to work with your code) pain.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You are mixing up the data step with macro code, which never works. As others have mentioned, macro statements have no access to values present in the data step. Why? Because the macro processor is a&amp;nbsp;&lt;STRONG&gt;pre&lt;/STRONG&gt;processor that prepares code, and does its work &lt;STRONG&gt;before&lt;/STRONG&gt; the data step is even compiled.&lt;/P&gt;
&lt;P&gt;You need to use arrays and the data step DO, no macro is needed at all.&lt;/P&gt;</description>
      <pubDate>Thu, 15 Apr 2021 11:30:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/do-to-macro-doenst-stop-after-match-a-condition/m-p/734197#M38551</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2021-04-15T11:30:03Z</dc:date>
    </item>
    <item>
      <title>Re: %do %to macro doenst stop after match a condition</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/do-to-macro-doenst-stop-after-match-a-condition/m-p/734275#M38563</link>
      <description>&lt;P&gt;This code makes no sense.&amp;nbsp; The macro variable DU will take on the single digit strings 0 thru 6 .&amp;nbsp; Any of those digits will always be larger than the letter Q.&amp;nbsp; So your macro is generating this data step code to run:&lt;/P&gt;
&lt;PRE&gt;MPRINT(LOOP):   DATA TESTE;
MPRINT(LOOP):   SET BASE_INFO_EXP2;
MPRINT(LOOP):   RISCO_M0 = VL_PRODUCAO;
MPRINT(LOOP):   JUROS_M0 = 0;
MPRINT(LOOP):   AMORT_M0 = 0;
MPRINT(LOOP):   JUROS_M1 = RISCO_M0 * (TAXA / 100);
MPRINT(LOOP):   AMORT_M1 = VL_PARCELA - JUROS_M1;
MPRINT(LOOP):   RISCO_M1 = RISCO_M0 - AMORT_M1;
MPRINT(LOOP):   JUROS_M2 = RISCO_M1 * (TAXA / 100);
MPRINT(LOOP):   AMORT_M2 = VL_PARCELA - JUROS_M2;
MPRINT(LOOP):   RISCO_M2 = RISCO_M1 - AMORT_M2;
MPRINT(LOOP):   JUROS_M3 = RISCO_M2 * (TAXA / 100);
MPRINT(LOOP):   AMORT_M3 = VL_PARCELA - JUROS_M3;
MPRINT(LOOP):   RISCO_M3 = RISCO_M2 - AMORT_M3;
MPRINT(LOOP):   JUROS_M4 = RISCO_M3 * (TAXA / 100);
MPRINT(LOOP):   AMORT_M4 = VL_PARCELA - JUROS_M4;
MPRINT(LOOP):   RISCO_M4 = RISCO_M3 - AMORT_M4;
MPRINT(LOOP):   JUROS_M5 = RISCO_M4 * (TAXA / 100);
MPRINT(LOOP):   AMORT_M5 = VL_PARCELA - JUROS_M5;
MPRINT(LOOP):   RISCO_M5 = RISCO_M4 - AMORT_M5;
MPRINT(LOOP):   JUROS_M6 = RISCO_M5 * (TAXA / 100);
MPRINT(LOOP):   AMORT_M6 = VL_PARCELA - JUROS_M6;
MPRINT(LOOP):   RISCO_M6 = RISCO_M5 - AMORT_M6;
MPRINT(LOOP):   RUN;
&lt;/PRE&gt;
&lt;P&gt;Which does not look very useful.&lt;/P&gt;
&lt;P&gt;If you want the data step to dynamically decide which of a series of variables to change the value of&amp;nbsp;then create an array and use a variable as the index into the array.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;...
array juros_m [6];
array amort_m [6];
array risco_m [6];
...
/* 
JUROS_M&amp;amp;DU. = RISCO_M&amp;amp;DU_AUX. * (TAXA / 100);
AMORT_M&amp;amp;DU. = VL_PARCELA - JUROS_M&amp;amp;DU.;
RISCO_M&amp;amp;DU. = RISCO_M&amp;amp;DU_AUX. - AMORT_M&amp;amp;DU.
*/
juros_m[du] = risco_m[du_aux] * (taxa/100);
amort_m[du] = vl_parcela -  juros_m[du];
risco_m[du] = risco_m[du_aux] - amort-m[du];
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 15 Apr 2021 13:39:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/do-to-macro-doenst-stop-after-match-a-condition/m-p/734275#M38563</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2021-04-15T13:39:43Z</dc:date>
    </item>
    <item>
      <title>Re: %do %to macro doenst stop after match a condition</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/do-to-macro-doenst-stop-after-match-a-condition/m-p/734285#M38564</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/11562"&gt;@Kurt_Bremser&lt;/a&gt;&amp;nbsp; i've made the change to array, however could you help me to resolve the problem of the variable M_AUX?&lt;/P&gt;&lt;P&gt;M_AUX should be i - 1.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;:'(&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;data teste;
SET TESTE2;
 risco_m0 = VL_PRODUCAO;
 array risco {6} risco_m1-risco_m6;
 do i = 1 to QT_PARCELA;
 	%LET M_AUX = %SYSFUNC(SUM(i,-1));
	 risco{i} = (RISCO_M&amp;amp;M_AUX. * (TAXA / 100));
 end;
run;&lt;/PRE&gt;&lt;P&gt;i get the follow error on log:&lt;/P&gt;&lt;PRE&gt;ERROR: Argument 1 to function SUM referenced by the %SYSFUNC or %QSYSFUNC macro function is not a number.&lt;BR /&gt;ERROR: Invalid arguments detected in %SYSCALL, %SYSFUNC, or %QSYSFUNC argument list. Execution of %SYSCALL statement or %SYSFUNC &lt;BR /&gt;or %QSYSFUNC function reference is terminated.&lt;/PRE&gt;</description>
      <pubDate>Thu, 15 Apr 2021 14:16:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/do-to-macro-doenst-stop-after-match-a-condition/m-p/734285#M38564</guid>
      <dc:creator>erickdt</dc:creator>
      <dc:date>2021-04-15T14:16:44Z</dc:date>
    </item>
    <item>
      <title>Re: %do %to macro doenst stop after match a condition</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/do-to-macro-doenst-stop-after-match-a-condition/m-p/734294#M38565</link>
      <description>&lt;P&gt;thanks all in advanced.. follow the solution:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;DATA TESTE;
SET TESTE2;
	 	RISCO_M0 = VL_PRODUCAO;
		JUROS_M0 = 0;
		AMORT_M0 = 0;
	 ARRAY JUROS {7} JUROS_M0-JUROS_M6;
	 ARRAY AMORT {7} AMORT_M0-AMORT_M6;
	 ARRAY RISCO {7} RISCO_M0-RISCO_M6;
		DO I = 2 TO QT_PARCELA+1;
			 	J = I -1;
					JUROS{I} =	(RISCO{J} * (TAXA / 100));
					AMORT{I} =	(VL_PARCELA - JUROS{I});
					RISCO{I} = 	 RISCO{J} 	- AMORT{I};

		END;
 DROP I J;
RUN;&lt;/PRE&gt;</description>
      <pubDate>Thu, 15 Apr 2021 14:38:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/do-to-macro-doenst-stop-after-match-a-condition/m-p/734294#M38565</guid>
      <dc:creator>erickdt</dc:creator>
      <dc:date>2021-04-15T14:38:18Z</dc:date>
    </item>
    <item>
      <title>Re: %do %to macro doenst stop after match a condition</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/do-to-macro-doenst-stop-after-match-a-condition/m-p/734312#M38566</link>
      <description>&lt;P&gt;So this is a nice simplified version of the same mistake that that original program had.&amp;nbsp; You are trying to use macro code where you want actual SAS code.&amp;nbsp; The macro code is evaluated before the data step starts running so you are running:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%LET M_AUX = %SYSFUNC(SUM(i,-1));

data teste;
SET TESTE2;
 risco_m0 = VL_PRODUCAO;
 array risco {6} risco_m1-risco_m6;
 do i = 1 to QT_PARCELA;
 	 risco{i} = (RISCO_M&amp;amp;M_AUX. * (TAXA / 100));
 end;
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;And all you need to do is put the subtraction in the index into the array.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt; do i = 1 to QT_PARCELA;
 	 risco{i} = (RISCO{i-1} * (TAXA / 100));
 end;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Now it is also easier to see another issue with this design.&amp;nbsp; If the index iterates from 1 to N then the second index will iterate from 0 to N-1.&amp;nbsp; &amp;nbsp;So you might want to change the starting value.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;do i = 2 to QT_PARCELA;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Or you can define the array to allow 0 as a valid index:.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt; array risco {0:5} risco_m1-risco_m6;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 15 Apr 2021 15:16:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/do-to-macro-doenst-stop-after-match-a-condition/m-p/734312#M38566</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2021-04-15T15:16:54Z</dc:date>
    </item>
  </channel>
</rss>

