<?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 timing - error - The macro C is still executing and cannot be redefined.A dummy macro will in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/macro-timing-error-The-macro-C-is-still-executing-and-cannot-be/m-p/439657#M109736</link>
    <description>&lt;P&gt;I am facing the same issue.&lt;/P&gt;&lt;P&gt;The macro 'c' works perfectly when stand alone, but when called in loop like -&amp;nbsp;&lt;/P&gt;&lt;P&gt;%macro a;&lt;/P&gt;&lt;P&gt;%do i=1 %to 20;&lt;/P&gt;&lt;P&gt;%c;&lt;/P&gt;&lt;P&gt;%end;&lt;/P&gt;&lt;P&gt;%mend;&lt;/P&gt;&lt;P&gt;%a;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;It gets stuck at some point and goes in never ending loop. And when forced 'STOP', any code I try to run that loop starts its run. Each time I had to close the project.&lt;/P&gt;</description>
    <pubDate>Fri, 23 Feb 2018 11:18:25 GMT</pubDate>
    <dc:creator>thepushkarsingh</dc:creator>
    <dc:date>2018-02-23T11:18:25Z</dc:date>
    <item>
      <title>macro timing - error - The macro C is still executing and cannot be redefined.A dummy macro will be compiled.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/macro-timing-error-The-macro-C-is-still-executing-and-cannot-be/m-p/118605#M24451</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi.&lt;/P&gt;&lt;P&gt;I've got problem apparently with some macro execution timing.&lt;/P&gt;&lt;P&gt;I've got macro A from which I execute macro C in a loop %do %while%.&lt;/P&gt;&lt;P&gt;I need to assure that macro C finished executing in iteration n before executing macro C in iteration n+1.&lt;/P&gt;&lt;P&gt;Now I get errors:&lt;/P&gt;&lt;P&gt;Line 696: ERROR: The macro C is still executing and cannot be redefined.&lt;/P&gt;&lt;P&gt;Line 697: ERROR: A dummy macro will be compiled.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;and in the log i see that some iterations of macro C did not start at all.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Is there a way to force SAS to woit for macro execution?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks for help.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 17 May 2012 11:58:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/macro-timing-error-The-macro-C-is-still-executing-and-cannot-be/m-p/118605#M24451</guid>
      <dc:creator>tom12122</dc:creator>
      <dc:date>2012-05-17T11:58:28Z</dc:date>
    </item>
    <item>
      <title>Re: macro timing - error - The macro C is still executing and cannot be redefined.A dummy macro will be compiled.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/macro-timing-error-The-macro-C-is-still-executing-and-cannot-be/m-p/118606#M24452</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Sounds like you have code like:&lt;/P&gt;&lt;P&gt;%macro a;&lt;/P&gt;&lt;P&gt;&amp;nbsp; %macro c;&lt;/P&gt;&lt;P&gt;&amp;nbsp; %mend c;&lt;/P&gt;&lt;P&gt;&amp;nbsp; %c;&lt;/P&gt;&lt;P&gt;%mend a;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Move the definition of macro c outside of the definition of macro a.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%macro c;&lt;/P&gt;&lt;P&gt;%mend c;&lt;/P&gt;&lt;P&gt;%macro a;&lt;/P&gt;&lt;P&gt;&amp;nbsp; %c;&lt;/P&gt;&lt;P&gt;%mend a;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 17 May 2012 12:21:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/macro-timing-error-The-macro-C-is-still-executing-and-cannot-be/m-p/118606#M24452</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2012-05-17T12:21:46Z</dc:date>
    </item>
    <item>
      <title>Re: macro timing - error - The macro C is still executing and cannot be redefined.A dummy macro will be compiled.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/macro-timing-error-The-macro-C-is-still-executing-and-cannot-be/m-p/118607#M24453</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;i have;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%macro c;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%mend c;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%macro a;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; %do %while ...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; %c;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; %end;&lt;/P&gt;&lt;P&gt;%mend a;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 17 May 2012 12:35:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/macro-timing-error-The-macro-C-is-still-executing-and-cannot-be/m-p/118607#M24453</guid>
      <dc:creator>tom12122</dc:creator>
      <dc:date>2012-05-17T12:35:17Z</dc:date>
    </item>
    <item>
      <title>Re: macro timing - error - The macro C is still executing and cannot be redefined.A dummy macro will be compiled.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/macro-timing-error-The-macro-C-is-still-executing-and-cannot-be/m-p/118608#M24454</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Next suspect is unbalanced quoting.&amp;nbsp; Try starting SAS fresh.&amp;nbsp; Does the macro A work the first time it is called?&lt;/P&gt;&lt;P&gt;Does it matter the values that are passed to it?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 17 May 2012 13:01:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/macro-timing-error-The-macro-C-is-still-executing-and-cannot-be/m-p/118608#M24454</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2012-05-17T13:01:08Z</dc:date>
    </item>
    <item>
      <title>Re: macro timing - error - The macro C is still executing and cannot be redefined.A dummy macro will</title>
      <link>https://communities.sas.com/t5/SAS-Programming/macro-timing-error-The-macro-C-is-still-executing-and-cannot-be/m-p/439657#M109736</link>
      <description>&lt;P&gt;I am facing the same issue.&lt;/P&gt;&lt;P&gt;The macro 'c' works perfectly when stand alone, but when called in loop like -&amp;nbsp;&lt;/P&gt;&lt;P&gt;%macro a;&lt;/P&gt;&lt;P&gt;%do i=1 %to 20;&lt;/P&gt;&lt;P&gt;%c;&lt;/P&gt;&lt;P&gt;%end;&lt;/P&gt;&lt;P&gt;%mend;&lt;/P&gt;&lt;P&gt;%a;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;It gets stuck at some point and goes in never ending loop. And when forced 'STOP', any code I try to run that loop starts its run. Each time I had to close the project.&lt;/P&gt;</description>
      <pubDate>Fri, 23 Feb 2018 11:18:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/macro-timing-error-The-macro-C-is-still-executing-and-cannot-be/m-p/439657#M109736</guid>
      <dc:creator>thepushkarsingh</dc:creator>
      <dc:date>2018-02-23T11:18:25Z</dc:date>
    </item>
    <item>
      <title>Re: macro timing - error - The macro C is still executing and cannot be redefined.A dummy macro will</title>
      <link>https://communities.sas.com/t5/SAS-Programming/macro-timing-error-The-macro-C-is-still-executing-and-cannot-be/m-p/439659#M109737</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Without knowing what the macro c contains, it is difficult to answer.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Could there be a conflict between macrovariables used in a and c ?&lt;/P&gt;
&lt;P&gt;For instance, if you use the same counter i in both macros they have&lt;/P&gt;
&lt;P&gt;to be declared as local.&lt;/P&gt;</description>
      <pubDate>Fri, 23 Feb 2018 11:26:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/macro-timing-error-The-macro-C-is-still-executing-and-cannot-be/m-p/439659#M109737</guid>
      <dc:creator>gamotte</dc:creator>
      <dc:date>2018-02-23T11:26:31Z</dc:date>
    </item>
    <item>
      <title>Re: macro timing - error - The macro C is still executing and cannot be redefined.A dummy macro will</title>
      <link>https://communities.sas.com/t5/SAS-Programming/macro-timing-error-The-macro-C-is-still-executing-and-cannot-be/m-p/439662#M109740</link>
      <description>&lt;P&gt;macro 'c':&lt;/P&gt;&lt;P&gt;%macro combos(trxn=);&lt;BR /&gt;%let I=1;&lt;BR /&gt;data _ben_;&lt;BR /&gt;set _benef_(obs=&amp;amp;I. firstobs=&amp;amp;I.);&lt;BR /&gt;if senders gt 1 then do;&lt;BR /&gt;call symput('n_connect',senders);&lt;BR /&gt;end;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;proc surveyselect&lt;BR /&gt;data= _senders_ (where=(trxn_per_benef=compress(&amp;amp;trxn.))) out= _sen_ method=srs n= Compress(&amp;amp;n_connect.) noprint;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;data _tmp_;&lt;BR /&gt;merge _ben_ _sen_;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;data _tmp_;&lt;BR /&gt;set _tmp_;&lt;BR /&gt;n=_n_;&lt;BR /&gt;if missing(benef_id) then&lt;BR /&gt;do;&lt;BR /&gt;do until (not missing(benef_id));&lt;BR /&gt;n=n-1;&lt;BR /&gt;set _tmp_(keep=benef_id n_ben_f senders in_trxn trxn_per_sender) point=n; *second SET statement;&lt;BR /&gt;end;&lt;BR /&gt;end;&lt;BR /&gt;run;&lt;BR /&gt;%reset;&lt;BR /&gt;%if &amp;amp;upto. &amp;gt;= 100 %then %goto exit;&lt;/P&gt;&lt;P&gt;%fill_s: %do I=&amp;amp;I. %to &amp;amp;upto.;&lt;BR /&gt;/*Switch to Senders*/&lt;BR /&gt;%fill_senders;&lt;BR /&gt;%end;&lt;BR /&gt;%reset;&lt;BR /&gt;%if &amp;amp;upto. &amp;gt;= 100 %then %goto exit;&lt;/P&gt;&lt;P&gt;%do I=&amp;amp;I. %to &amp;amp;upto.;&lt;BR /&gt;/*Switch to Recipients*/&lt;BR /&gt;%fill_benefs;&lt;BR /&gt;%end;&lt;BR /&gt;%reset;&lt;BR /&gt;%if &amp;amp;upto. &amp;lt; 100 %then %goto fill_s;&lt;BR /&gt;%exit:&lt;/P&gt;&lt;P&gt;%mend;&lt;BR /&gt;%combos(trxn=1);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Macro 'a' :&lt;/P&gt;&lt;P&gt;%macro create_combos;&lt;/P&gt;&lt;P&gt;%do t=1 %to 20;&lt;/P&gt;&lt;P&gt;%combos(trxn=&amp;amp;t.);&lt;/P&gt;&lt;P&gt;%end;&lt;/P&gt;&lt;P&gt;%mend;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But then again the other two macros 'fill_benefs' and 'fill_senders' are using macro variables 'I' and 'TRXN', common to them but I need them as start from the value one ends like if 'I' ends in %fill_benefs at 15, I need the I starting from 16 in %fill_senders.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 23 Feb 2018 11:37:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/macro-timing-error-The-macro-C-is-still-executing-and-cannot-be/m-p/439662#M109740</guid>
      <dc:creator>thepushkarsingh</dc:creator>
      <dc:date>2018-02-23T11:37:59Z</dc:date>
    </item>
    <item>
      <title>Re: macro timing - error - The macro C is still executing and cannot be redefined.A dummy macro will</title>
      <link>https://communities.sas.com/t5/SAS-Programming/macro-timing-error-The-macro-C-is-still-executing-and-cannot-be/m-p/439678#M109746</link>
      <description>&lt;P&gt;Please use the" little running man" icon to post code with proper identation.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro combos(trxn=);

    %let I=1;
    
    data _ben_;
        set _benef_(obs=&amp;amp;I. firstobs=&amp;amp;I.);
        if senders gt 1 then do;
            call symput('n_connect',senders);
        end;
    run;

    proc surveyselect
        data= _senders_ (where=(trxn_per_benef=compress(&amp;amp;trxn.))) out= _sen_ method=srs n= Compress(&amp;amp;n_connect.) noprint;
    run;

    data _tmp_;
        merge _ben_ _sen_;
    run;

    data _tmp_;
        set _tmp_;
        n=_n_;
        if missing(benef_id) then
        do;
            do until (not missing(benef_id));
                n=n-1;
                set _tmp_(keep=benef_id n_ben_f senders in_trxn trxn_per_sender) point=n; *second SET statement;
            end;
        end;
    run;

    %reset;
    
    %if &amp;amp;upto. &amp;gt;= 100 %then %goto exit;

    %fill_s: 

    %do I=&amp;amp;I. %to &amp;amp;upto.;
        /*Switch to Senders*/
        %fill_senders;
    %end;
    
    %reset;
    
    %if &amp;amp;upto. &amp;gt;= 100 %then %goto exit;

    %do I=&amp;amp;I. %to &amp;amp;upto.;
        /*Switch to Recipients*/
        %fill_benefs;
    %end;

    %reset;
    
    %if &amp;amp;upto. &amp;lt; 100 %then %goto fill_s;
    
    %exit:

%mend;

%macro create_combos;

    %do t=1 %to 20;

        %combos(trxn=&amp;amp;t.);

    %end;

%mend;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;You still have loops calling macros that are black boxes to us. Do these macro modify the macrovariable upto ?&lt;/P&gt;
&lt;P&gt;If not why testing the same condition several times. Insetad of using gotos, you should enlose treatments with do end&lt;/P&gt;
&lt;P&gt;so that it's easier to follow the logic.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You initialize loops on macrovariable I with its own value &amp;amp;i. I guess the reset macro reinitialise I otherwise your second loop will then go from &amp;amp;upto+1 to &amp;amp;upto. which i doubt you really want. &lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Can you try to post a minimal executable example replicating the issue ?&lt;/P&gt;</description>
      <pubDate>Fri, 23 Feb 2018 13:03:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/macro-timing-error-The-macro-C-is-still-executing-and-cannot-be/m-p/439678#M109746</guid>
      <dc:creator>gamotte</dc:creator>
      <dc:date>2018-02-23T13:03:36Z</dc:date>
    </item>
    <item>
      <title>Re: macro timing - error - The macro C is still executing and cannot be redefined.A dummy macro will</title>
      <link>https://communities.sas.com/t5/SAS-Programming/macro-timing-error-The-macro-C-is-still-executing-and-cannot-be/m-p/439681#M109747</link>
      <description>&lt;P&gt;As you said, in some cases I got stuck with "&lt;SPAN&gt;otherwise your second loop will then go from &amp;amp;upto+1 to &amp;amp;upto.". Thanks a lot!&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 23 Feb 2018 13:08:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/macro-timing-error-The-macro-C-is-still-executing-and-cannot-be/m-p/439681#M109747</guid>
      <dc:creator>thepushkarsingh</dc:creator>
      <dc:date>2018-02-23T13:08:41Z</dc:date>
    </item>
    <item>
      <title>Re: macro timing - error - The macro C is still executing and cannot be redefined.A dummy macro will</title>
      <link>https://communities.sas.com/t5/SAS-Programming/macro-timing-error-The-macro-C-is-still-executing-and-cannot-be/m-p/439685#M109748</link>
      <description>&lt;P&gt;The first line of the inner macro should give a good hint into the most likely source of your problem.&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;&lt;SPAN&gt;%macro combos(trxn=);&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;%let I=1;&lt;/SPAN&gt;&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&lt;SPAN&gt;Macro variable scoping.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;If the environment that has called %COMBOS() already had a macro variable named I that it was using to control a loop then the first line in COMBOS just changed the value of that existing macro variable.&amp;nbsp; Follow these simple rules and you should be ok.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;&lt;SPAN&gt;Always define your macro variable's scope before you use them.&lt;/SPAN&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;SPAN&gt;Unless you intend to modify an existing macro variable or need to reference the value after the macro finishes then define your macro variable as LOCAL.&lt;/SPAN&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;SPAN&gt;Always test if a macro variable exists before defining it as GLOBAL.&lt;/SPAN&gt;&lt;/LI&gt;
&lt;/OL&gt;
&lt;P&gt;The macro COMBOS has defined one local macro variable TRXN (all parameters are by definition local macro variables) but it is referencing these macro variables without defining their scope.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;I
N_CONNECT
UPTO&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;And it is also calling other macros that might be lackadaisical in their use of macro variable scoping.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 23 Feb 2018 15:29:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/macro-timing-error-The-macro-C-is-still-executing-and-cannot-be/m-p/439685#M109748</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2018-02-23T15:29:13Z</dc:date>
    </item>
  </channel>
</rss>

