03-11-2014 08:59 AM
I have a number of macro programs that take different data sets for processing.
%macro Abc; /* Takes data set abc*/
This way I have created a number of macro programs.
Now I need to execute macro program 'Abc' if data set Abc exists,
%IF %SYSFUNC(EXIST(Dsn))>0 %THEN %DO;
%(&Dsn); /*Here is the problem*/
%PUT***********Dataset &Dsn does not exist;
Now if I use
%Action(Abc); The program fails to execute because in %(&Dsn) , &Dsn fails to resolve so %Abc does not execute.
Is there a way to fix this?
Thanks every one for your attention.
03-11-2014 09:08 AM
You have brackets around the &dsn., the below works (I note you also miss the ampersand on the exists function):
%macro action (dsn);
Although I would suggest there are better ways of doing something like this than having a macro per dataset, even creating one macro which accepts the dataset as a parameter:
%macro do_something (dset=);
Or alternatively create a loop dataset and then use that to generate code with call execute.
03-11-2014 10:36 AM
This sounds like a bad design.
Perhaps explain more about what you're trying to do and someone can suggest better design techniques.
03-11-2014 12:15 PM
That is because the code the macro generated: %(abc) is not valid syntax for a macro call. You want it to generate %abc; or %abc() .