BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
hellohere
Pyrite | Level 9

I am to systematically summ-up info., invoking macros inside dataset.

The code is fine; the macros are clearly invoked [see LOG, macro variable values are show].

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.

The sql need take quite seconds to finish. BUT here is totally ignored and takes no time to exit the macro. 

 

CODE and LOG are below. 

	/*put all the code, including the ones with condi. here*/
	%macro tocall(date, xst, xend, mm_ind);
		/*create the dataset*/
		proc sql;
		create table &indexout._&dt._p2x as
		select a.*, 
			b.ind, 
			c.lp_prev_grp as lp_prev_grp/*,
			d.wt_grp, 
			d.hibetaflag*/
		from &indexout._&dt._pout_wt as b 
		left join &indexout._&dt._p as a
		on a._time_=b._time_
		left join &indexout._&dt._lp_prev as c
		on a.tick=c.tick
		/*left join &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 &indexout._&dt._p2x; if ind=&xst.; 	run;quit;
		data _temp_lp_end(keep=tick _time_ lp ind rename=(lp=lp_end)); 	set &indexout._&dt._p2x; if ind=&xend.; run;quit;

		%summ_show(&date., &xst., &xend., &mm_ind., , , );

	%mend;

	%macro summ_show(date, xst, xend, mm_ind, wtcalc1, wtcalc2, condi);
		put "here inside summ_show(...)";
	%mend;

	data _null_;
	set &indexout._&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;
3628      %macro tocall(date, xst, xend, mm_ind);
3629          /*create the dataset*/
3630          proc sql;
3631          create table &indexout._&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 &indexout._&dt._pout_wt as b
3638          left join &indexout._&dt._p as a
3639          on a._time_=b._time_
3640          left join &indexout._&dt._lp_prev as c
3641          on a.tick=c.tick
3642          /*left join &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! &indexout._&dt._p2x; if ind=&xst.;  run;quit;
3648          data _temp_lp_end(keep=tick _time_ lp ind rename=(lp=lp_end));  set
3648! &indexout._&dt._p2x; if ind=&xend.; run;quit;
3649
3650          %summ_show(&date., &xst., &xend., &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 &indexout._&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.

 

1 ACCEPTED SOLUTION
3 REPLIES 3
hellohere
Pyrite | Level 9

Now even the proc sql is taken out and replaced with simple data step. The data step is NOT exe'd. 

 

	%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 &indexout._&dt._p2x; if ind=&xst.; 	run;quit;
		data _temp_lp_end(keep=tick _time_ lp ind rename=(lp=lp_end)); 	set &indexout._&dt._p2x; if ind=&xend.; run;quit;

		%summ_show(&date., &xst., &xend., &mm_ind., , , );

	%mend;

	%macro summ_show(date, xst, xend, mm_ind, wtcalc1, wtcalc2, condi);
		put "here inside summ_show(...)";
	%mend;

	data _null_;
	set &indexout._&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;

 

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! &indexout._&dt._p2x; if ind=&xst.;  run;quit;
3719          data _temp_lp_end(keep=tick _time_ lp ind rename=(lp=lp_end));  set
3719! &indexout._&dt._p2x; if ind=&xend.; run;quit;
3720
3721          %summ_show(&date., &xst., &xend., &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 &indexout._&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.

Tom
Super User Tom
Super User

To see where the "code" that the macro emitted went check the value of the RESULT variable in your driving dataset.

data _null_;
  set &indexout._&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;

 

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

Register Now

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 3 replies
  • 202 views
  • 2 likes
  • 3 in conversation