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 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
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
  • 4 replies
  • 761 views
  • 0 likes
  • 3 in conversation