NO, macro programming could contain a data step program that used LINK, but (as I have indicated in previous postings) this is still the relevant answer to what you say you want (which I understand to be the ability to conditionally execute whole chunks of code based on the value of some macro variable or data step variable value):
[pre]
%macro dorept;
%IF &macvar = something %THEN %DO;
%let title = 'Weekly Report';
proc sql;
sql statements go here;
quit;
%END;
%ELSE %IF &macvar = otherthing %THEN %DO;
%let title = 'Daily Report';
proc report goes here
%END;
%mend dorept;
%dorept;
[/pre]
All macro conditional logic MUST be contained within a SAS macro PROGRAM (a SAS Macro Program is contained within %MACRO and %MEND statements). A macro program is like a big typewriter.
It can type one variable name for you, one statement, part of a statement, a whole step, part of a step, a call to another macro ..... you are probably only limited by your imagination and macro programming skills. You MAY use LINK within a DATA step program. You MAY have a DATA step program contained within a SAS Macro program. But your example, as shown below, would NOT work.
[pre]
%If suchandsuch %then
LINK here;
%else %if someotherthing %then
LINK there;
end;
here:
proc sql;
sql code goes here
quit;
there
proc report;
report code goes here
run;
[/pre]
INSTEAD, you would have something more like this:
[pre]
%macro here;
proc sql;
sql code goes here
quit;
%mend here;
* this code is now invokable as '%here' (without quotes);
%macro there;
proc report;
report code goes here
run;
%mend there;
*this code is now invokable as '%there' (without quotes);
%macro runrept;
%If &macvar = suchandsuch %then %do;
%here;
%else %if &macvar = someotherthing %then %do;
%there;
%end;
%mend runrept;
** this code is now invokable as '%runrept' and since it calls the other 2 macro programs;
** I can invoke all 3 essentially by doing this: ;
%runrept;
[/pre]
Note that we have not talked yet about how &macvar will get values. When you're testing, you will set values for &macvar with %let statements. As a stored process, &macvar will get a value from the client application when the user supplies a value for an input parameter.
I think that you really need to consult with Tech Support on the design of these macro programs if you eventually want to turn this code into a stored process. As always, I recommend a 4 step approach:
1) have a working SAS program that executes correctly in an EG code node or from Display Manager with hardcoded values for all selection criteria;
2) take the program from #1 and "macro-ize" it with macro variables. Test the program in an EG code node or from SAS Display Manager by populating the macro variable values with %LET statements;
3) Turn the program from #2 into a MACRO program and add the MACRO conditional logic that you need to implement to make the macro generate all the outputs that you want.
4) When the MACRO program from #3 is working correctly, THEN and ONLY THEN, turn the #3 program into a stored process.
I know it may seem better to just jump into macro programming and turn out a stored process, but a measured approach through steps 1, 2 and 3 -- outside the realm of stored processes -- will, in my opinion, net you the best results with the least heartache. Debugging macro programs is hard enough when you're looking at the SAS log -- let alone having to deal with a client/server situation and the added complexity of stored processes.
cynthia