BookmarkSubscribeRSS Feed
lyton80
Obsidian | Level 7

Hello all;

I have 8 macros to run in sequence. It is imperative that one completes before the other starts.

The macros would be run on 10 datasets with names that increase by 1.

How can I do this in a %Macro do loop while ensuring that one macro completes before the other starts?

Thanks in advance.

Stan.

2 REPLIES 2
Reeza
Super User

How are you calling them currently?

I believe the default behaviour is to wait for one process to finish before starting others, so unless you change something that's what will happen.

FriedEgg
SAS Employee

Statements entered in SAS are executed sequentially, so you shouldn't have any real concerns about the process flow (of course there are exceptions, but I would not believe any of them apply here at a novice level).

*list the macro's sequentially;

%mymacro1

%mymacro2

%mymacro3

%myfourthmacro

...

%mymacro10

%myothermacro

*call macro's from a macro with same name plus numerical suffix;

%macro mymacrocaller;

%do i = 1 %to 10;

  %let lmacname = mymacro&i;

  %&lmacname

%end;

%mend;

%mymacrocaller

*call list of macro's when names are different;

%macro mymaccall;

%let maclist=mymac1 secondone lastone;

%do i = 1 %to %sysfunc(countw(&maclist));

%let lmacn=%scan(&maclist,&i);

%&lmacn

%end;

%mend;

*call list of macro's from a datastep;

data _null_;

infile cards;

input macname $;

call execute(cats('%nrstr(%',macname,')'));

cards4;

mymacro1

foobar

lasagna

;;;;

There are plenty of other ways to do it as well, but the exact problem is not completely apparent from your question.

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
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
  • 2 replies
  • 1335 views
  • 0 likes
  • 3 in conversation