BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
xiangpang
Quartz | Level 8

Hello,

 

I want to compare the running time difference of a large MACRO with several different small macro. 

For example. one is %macro A and another is %micro B. what code I should use and where I should input?


%micro A; %micro bb; %micro ccc; %mend ccc; %mend bb; %mend A; %micro B; %micro bb; %micro ccc; %micro dddd; %mend dddd; %mend ccc; %mend bb; %mend B;

Thanks a lot

1 ACCEPTED SOLUTION

Accepted Solutions
Reeza
Super User

https://blogs.sas.com/content/sgf/2015/01/21/sas-timer-the-key-to-writing-efficient-sas-code/

 


@xiangpang wrote:

Hello,

 

I want to compare the running time difference of a large MACRO with several different small macro. 

For example. one is %macro A and another is %micro B. what code I should use and where I should input?


%micro A; %micro bb; %micro ccc; %mend ccc; %mend bb; %mend A; %micro B; %micro bb; %micro ccc; %micro dddd; %mend dddd; %mend ccc; %mend bb; %mend B;

Thanks a lot


 

View solution in original post

4 REPLIES 4
Reeza
Super User

https://blogs.sas.com/content/sgf/2015/01/21/sas-timer-the-key-to-writing-efficient-sas-code/

 


@xiangpang wrote:

Hello,

 

I want to compare the running time difference of a large MACRO with several different small macro. 

For example. one is %macro A and another is %micro B. what code I should use and where I should input?


%micro A; %micro bb; %micro ccc; %mend ccc; %mend bb; %mend A; %micro B; %micro bb; %micro ccc; %micro dddd; %mend dddd; %mend ccc; %mend bb; %mend B;

Thanks a lot


 

xiangpang
Quartz | Level 8

Thank you very much.

Tom
Super User Tom
Super User

I think you got an answer to your question but the code you posted is very puzzling. It seems to show marco DEFINITIONS nested inside of each other. 

 

You should NEVER do that.

 

You can call another macro inside of a macro, so that when it runs they are nested.  But the store of compiled macros is a flat directory.  At any point in time you can only have one macro named CCC.  You cannot have one defined inside of A and a different one that is defined only when B is running.   If you compile a new definition of CCC it overwrites the previous definition of CCC.

%macro A;
  %put Inside A;
  %bb;
  %put Back to A;
%mend A;
%macro bb;
  %put Inside BB;
  %ccc;
  %put Back to BB;
%mend bb;
%macro ccc;
  %put Inside CCC ;
%mend ccc;
317  %A;
Inside A
Inside BB
Inside CCC
MPRINT(BB):  ;
Back to BB
MPRINT(A):  ;
Back to A

 

 

xiangpang
Quartz | Level 8
Sorry for the confuse. I run macroA and macroB in different dataset at different time. Thanks for the comment. I am still a beginner and thanks for teaching.

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 4 replies
  • 524 views
  • 0 likes
  • 3 in conversation