<?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: Why Macros are invoked but Part is not exe'd?! or NONE is exe'd?! in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Why-Macros-are-invoked-but-Part-is-not-exe-d-or-NONE-is-exe-d/m-p/975057#M378035</link>
    <description>&lt;P&gt;For further clarification:&lt;/P&gt;
&lt;P&gt;RESOLVE can only resolve macro elements, but it can not execute the resulting code.&lt;/P&gt;
&lt;P&gt;If macro elements within a macro are meant to be created/changed by non-macro code contained in the macro, this will not work as intended, as the non-macro code will never run.&lt;/P&gt;
&lt;P&gt;CALL EXECUTE, OTOH, feeds code into the execution queue. But you need to take care when a macro is involved, as macro triggers will be resolved immediately while all other code can only run after the current step finishes. Therefore, %NRSTR is needed to mask macro code during the insertion into the execution queue; it will then be resolved when code is fetched from the queue.&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 15 Sep 2025 10:03:41 GMT</pubDate>
    <dc:creator>Kurt_Bremser</dc:creator>
    <dc:date>2025-09-15T10:03:41Z</dc:date>
    <item>
      <title>Why Macros are invoked but Part is not exe'd?! or NONE is exe'd?!</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Why-Macros-are-invoked-but-Part-is-not-exe-d-or-NONE-is-exe-d/m-p/975000#M378005</link>
      <description>&lt;P&gt;I am to systematically summ-up info., invoking macros inside dataset.&lt;/P&gt;
&lt;P&gt;The code is fine; the macros are clearly invoked [see LOG, macro variable values are show].&lt;/P&gt;
&lt;P&gt;BUT the proc sql and simple put line are not exe'd. The SQL, not taking pass-throu variables, is fine and the result dataset can be created.&lt;/P&gt;
&lt;P&gt;The sql need take quite seconds to finish. BUT here is totally ignored and takes no time to exit the macro.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;CODE and LOG are below.&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;	/*put all the code, including the ones with condi. here*/
	%macro tocall(date, xst, xend, mm_ind);
		/*create the dataset*/
		proc sql;
		create table &amp;amp;indexout._&amp;amp;dt._p2x as
		select a.*, 
			b.ind, 
			c.lp_prev_grp as lp_prev_grp/*,
			d.wt_grp, 
			d.hibetaflag*/
		from &amp;amp;indexout._&amp;amp;dt._pout_wt as b 
		left join &amp;amp;indexout._&amp;amp;dt._p as a
		on a._time_=b._time_
		left join &amp;amp;indexout._&amp;amp;dt._lp_prev as c
		on a.tick=c.tick
		/*left join &amp;amp;indexout. as d
		on a.tick=d.tick*/
		order by a.tick, a._time_;
		quit;

		data _temp_lp_st(keep=tick _time_ lp ind rename=(lp=lp_st.)); 	set &amp;amp;indexout._&amp;amp;dt._p2x; if ind=&amp;amp;xst.; 	run;quit;
		data _temp_lp_end(keep=tick _time_ lp ind rename=(lp=lp_end)); 	set &amp;amp;indexout._&amp;amp;dt._p2x; if ind=&amp;amp;xend.; run;quit;

		%summ_show(&amp;amp;date., &amp;amp;xst., &amp;amp;xend., &amp;amp;mm_ind., , , );

	%mend;

	%macro summ_show(date, xst, xend, mm_ind, wtcalc1, wtcalc2, condi);
		put "here inside summ_show(...)";
	%mend;

	data _null_;
	set &amp;amp;indexout._&amp;amp;dt._mm_ind; 
	if missing(lp_st_ind)=0 and missing(lp_end_ind)=0 and _N_=3 then do;
		result=resolve(cats('%tocall(',catx(',',date,lp_st_ind, lp_end_ind, mm_ind),')'));
	end;	
	run;quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;3628      %macro tocall(date, xst, xend, mm_ind);
3629          /*create the dataset*/
3630          proc sql;
3631          create table &amp;amp;indexout._&amp;amp;dt._p2x as
3632          select a.*,
3633              b.ind,
3634              c.lp_prev_grp as lp_prev_grp/*,
3635              d.wt_grp,
3636              d.hibetaflag*/
3637          from &amp;amp;indexout._&amp;amp;dt._pout_wt as b
3638          left join &amp;amp;indexout._&amp;amp;dt._p as a
3639          on a._time_=b._time_
3640          left join &amp;amp;indexout._&amp;amp;dt._lp_prev as c
3641          on a.tick=c.tick
3642          /*left join &amp;amp;indexout. as d
3643          on a.tick=d.tick*/
3644          order by a.tick, a._time_;
3645          quit;
3646
3647          data _temp_lp_st(keep=tick _time_ lp ind rename=(lp=lp_st));    set
3647! &amp;amp;indexout._&amp;amp;dt._p2x; if ind=&amp;amp;xst.;  run;quit;
3648          data _temp_lp_end(keep=tick _time_ lp ind rename=(lp=lp_end));  set
3648! &amp;amp;indexout._&amp;amp;dt._p2x; if ind=&amp;amp;xend.; run;quit;
3649
3650          %summ_show(&amp;amp;date., &amp;amp;xst., &amp;amp;xend., &amp;amp;mm_ind., , , );
3651
3652      %mend;
3653
3654      %macro summ_show(date, xst, xend, mm_ind, wtcalc1, wtcalc2, condi);
3655          put "here inside summ_show(...)";
3656      %mend;

3657      data _null_;
3658      set &amp;amp;indexout._&amp;amp;dt._mm_ind;
3659      if missing(lp_st_ind)=0 and missing(lp_end_ind)=0 and _N_=3 then do;
3660          result=resolve(cats('%tocall(',catx(',',date,lp_st_ind, lp_end_ind,
3660! mm_ind),')'));
3661      end;
3662      run;

3662!         quit;
MLOGIC(TOCALL):  Beginning execution.
MLOGIC(TOCALL):  Parameter DATE has value 0827
MLOGIC(TOCALL):  Parameter XST has value 747
MLOGIC(TOCALL):  Parameter XEND has value 1647
MLOGIC(TOCALL):  Parameter MM_IND has value 3369
NOTE: DATA statement used (Total process time):
      real time           0.04 seconds
      cpu time            0.04 seconds

MLOGIC(SUMM_SHOW):  Beginning execution.
MLOGIC(SUMM_SHOW):  Parameter DATE has value 0827
MLOGIC(SUMM_SHOW):  Parameter XST has value 747
MLOGIC(SUMM_SHOW):  Parameter XEND has value 1647
MLOGIC(SUMM_SHOW):  Parameter MM_IND has value 3369
MLOGIC(SUMM_SHOW):  Parameter WTCALC1 has value
MLOGIC(SUMM_SHOW):  Parameter WTCALC2 has value
MLOGIC(SUMM_SHOW):  Parameter CONDI has value
MLOGIC(SUMM_SHOW):  Ending execution.
MLOGIC(TOCALL):  Ending execution.
NOTE: There were 9 observations read from the data set WORK.ZZ500_0827_MM_IND.
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 14 Sep 2025 08:23:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Why-Macros-are-invoked-but-Part-is-not-exe-d-or-NONE-is-exe-d/m-p/975000#M378005</guid>
      <dc:creator>hellohere</dc:creator>
      <dc:date>2025-09-14T08:23:48Z</dc:date>
    </item>
    <item>
      <title>Re: Why Macros are invoked but Part is not exe'd?! or NONE is exe'd?!</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Why-Macros-are-invoked-but-Part-is-not-exe-d-or-NONE-is-exe-d/m-p/975001#M378006</link>
      <description>&lt;P&gt;Now even the proc sql is taken out and replaced with simple data step. The data step is NOT exe'd.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;	%macro tocall(date, xst, xend, mm_ind);
		data _temp;
		do i=1 to 10;
			do j=1 to 100;
				x=i*100+j; output;
			end;
		end;
		run;quit;

		data _temp_lp_st(keep=tick _time_ lp ind rename=(lp=lp_st.)); 	set &amp;amp;indexout._&amp;amp;dt._p2x; if ind=&amp;amp;xst.; 	run;quit;
		data _temp_lp_end(keep=tick _time_ lp ind rename=(lp=lp_end)); 	set &amp;amp;indexout._&amp;amp;dt._p2x; if ind=&amp;amp;xend.; run;quit;

		%summ_show(&amp;amp;date., &amp;amp;xst., &amp;amp;xend., &amp;amp;mm_ind., , , );

	%mend;

	%macro summ_show(date, xst, xend, mm_ind, wtcalc1, wtcalc2, condi);
		put "here inside summ_show(...)";
	%mend;

	data _null_;
	set &amp;amp;indexout._&amp;amp;dt._mm_ind; 
	if missing(lp_st_ind)=0 and missing(lp_end_ind)=0 and _N_=3 then do;
		result=resolve(cats('%tocall(',catx(',',date,lp_st_ind, lp_end_ind, mm_ind),')'));
	end;	
	run;quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;3709      %macro tocall(date, xst, xend, mm_ind);
3710          data _temp;
3711          do i=1 to 10;
3712              do j=1 to 100;
3713                  x=i*100+j; output;
3714              end;
3715          end;
3716          run;quit;
3717
3718          data _temp_lp_st(keep=tick _time_ lp ind rename=(lp=lp_st.));   set
3718! &amp;amp;indexout._&amp;amp;dt._p2x; if ind=&amp;amp;xst.;  run;quit;
3719          data _temp_lp_end(keep=tick _time_ lp ind rename=(lp=lp_end));  set
3719! &amp;amp;indexout._&amp;amp;dt._p2x; if ind=&amp;amp;xend.; run;quit;
3720
3721          %summ_show(&amp;amp;date., &amp;amp;xst., &amp;amp;xend., &amp;amp;mm_ind., , , );
3722
3723      %mend;
3724
3725      %macro summ_show(date, xst, xend, mm_ind, wtcalc1, wtcalc2, condi);
3726          put "here inside summ_show(...)";
3727      %mend;

3728      data _null_;
3729      set &amp;amp;indexout._&amp;amp;dt._mm_ind;
3730      if missing(lp_st_ind)=0 and missing(lp_end_ind)=0 and _N_=3 then do;
3731          result=resolve(cats('%tocall(',catx(',',date,lp_st_ind, lp_end_ind,
3731! mm_ind),')'));
3732      end;
3733      run;

3733!         quit;
MLOGIC(TOCALL):  Beginning execution.
MLOGIC(TOCALL):  Parameter DATE has value 0827
MLOGIC(TOCALL):  Parameter XST has value 747
MLOGIC(TOCALL):  Parameter XEND has value 1647
MLOGIC(TOCALL):  Parameter MM_IND has value 3369
NOTE: DATA statement used (Total process time):
      real time           0.01 seconds
      cpu time            0.01 seconds

MLOGIC(SUMM_SHOW):  Beginning execution.
MLOGIC(SUMM_SHOW):  Parameter DATE has value 0827
MLOGIC(SUMM_SHOW):  Parameter XST has value 747
MLOGIC(SUMM_SHOW):  Parameter XEND has value 1647
MLOGIC(SUMM_SHOW):  Parameter MM_IND has value 3369
MLOGIC(SUMM_SHOW):  Parameter WTCALC1 has value
MLOGIC(SUMM_SHOW):  Parameter WTCALC2 has value
MLOGIC(SUMM_SHOW):  Parameter CONDI has value
MLOGIC(SUMM_SHOW):  Ending execution.
MLOGIC(TOCALL):  Ending execution.
NOTE: There were 9 observations read from the data set WORK.ZZ500_0827_MM_IND.

&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 14 Sep 2025 08:34:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Why-Macros-are-invoked-but-Part-is-not-exe-d-or-NONE-is-exe-d/m-p/975001#M378006</guid>
      <dc:creator>hellohere</dc:creator>
      <dc:date>2025-09-14T08:34:23Z</dc:date>
    </item>
    <item>
      <title>Re: Why Macros are invoked but Part is not exe'd?! or NONE is exe'd?!</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Why-Macros-are-invoked-but-Part-is-not-exe-d-or-NONE-is-exe-d/m-p/975003#M378008</link>
      <description>Instead of RESOLVE, use CALL EXECUTE.&lt;BR /&gt;&lt;BR /&gt;To prevent premature execution of macro code, wrap the macro call in %NRSTR.</description>
      <pubDate>Sun, 14 Sep 2025 08:48:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Why-Macros-are-invoked-but-Part-is-not-exe-d-or-NONE-is-exe-d/m-p/975003#M378008</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2025-09-14T08:48:05Z</dc:date>
    </item>
    <item>
      <title>Re: Why Macros are invoked but Part is not exe'd?! or NONE is exe'd?!</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Why-Macros-are-invoked-but-Part-is-not-exe-d-or-NONE-is-exe-d/m-p/975013#M378014</link>
      <description>&lt;P&gt;To see where the "code" that the macro emitted went check the value of the RESULT variable in your driving dataset.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
  set &amp;amp;indexout._&amp;amp;dt._mm_ind; 
  if missing(lp_st_ind)=0 and missing(lp_end_ind)=0 and _N_=3 then do;
    result=resolve(cats('%tocall(',catx(',',date,lp_st_ind, lp_end_ind, mm_ind),')'));
    put result=;
  end;	
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 14 Sep 2025 14:58:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Why-Macros-are-invoked-but-Part-is-not-exe-d-or-NONE-is-exe-d/m-p/975013#M378014</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2025-09-14T14:58:54Z</dc:date>
    </item>
    <item>
      <title>Re: Why Macros are invoked but Part is not exe'd?! or NONE is exe'd?!</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Why-Macros-are-invoked-but-Part-is-not-exe-d-or-NONE-is-exe-d/m-p/975057#M378035</link>
      <description>&lt;P&gt;For further clarification:&lt;/P&gt;
&lt;P&gt;RESOLVE can only resolve macro elements, but it can not execute the resulting code.&lt;/P&gt;
&lt;P&gt;If macro elements within a macro are meant to be created/changed by non-macro code contained in the macro, this will not work as intended, as the non-macro code will never run.&lt;/P&gt;
&lt;P&gt;CALL EXECUTE, OTOH, feeds code into the execution queue. But you need to take care when a macro is involved, as macro triggers will be resolved immediately while all other code can only run after the current step finishes. Therefore, %NRSTR is needed to mask macro code during the insertion into the execution queue; it will then be resolved when code is fetched from the queue.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 15 Sep 2025 10:03:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Why-Macros-are-invoked-but-Part-is-not-exe-d-or-NONE-is-exe-d/m-p/975057#M378035</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2025-09-15T10:03:41Z</dc:date>
    </item>
  </channel>
</rss>

