Hi!
The way you conditionally execute entire steps or partial sections of code is by using SAS Macro programming conditional logic.
In this previous post,
http://support.sas.com/forums/thread.jspa?messageID=5944
the code showed running a weekly report vs running a daily report using Macro conditional logic. That example is relevant to your question.
The SAS Macro facility is like a big typewriter. You can do something as simple as this:
[pre]
** generate 1 PROC PRINT depending on the value of macro var;
proc print data=sashelp.class;
%if %upcase(&macvar) = ONE %then %do;
Title 'One Title';
var name age height;
%end;
%else %if %upcase(&macvar) = TWO %then %do;
Title 'Other Title';
var name sex age height weight;
%end;
run;
[/pre]
What is inside the %IF could be a piece of one step, or could be a WHOLE step:
[pre]
** generate an entire section of code or a different section of code;
%if %upcase(&macvar) = ONE %then %do;
proc print data=sashelp.class;
Title 'Whole PROC PRINT Step';
var name age height;
run;
%end;
%else %if %upcase(&macvar) = TWO %then %do;
proc sql;
create table wombat as
select * from sashelp.class
where age gt 13;
quit;
proc print data=wombat;
title 'Other Condition';
run;
%end;
[/pre]
The only limitation is that conditional macro logic must be contained within a SAS Macro program (a piece of code that you define with a
%MACRO/%MEND section).
So, as a stored process, the code would look something like this:
[pre]
%global macvar;
%macro ckparms;
%if %upcase(&macvar) = ONE %then %do;
proc print data=sashelp.class;
Title 'Whole PROC PRINT Step';
var name age height;
run;
%end;
%else %if %upcase(&macvar) = TWO %then %do;
proc sql;
create table wombat as
select * from sashelp.class
where age gt 13;
quit;
proc print data=wombat;
title 'Other Condition';
run;
%end;
proc freq data=sashelp.shoes;
tables region;
title 'PROC FREQ will run for BOTH values of &MACVAR';
title2 "Current value of MACVAR= &macvar";
run;
%mend ckparms;
%stpbegin;
%ckparms;
%stpend;
[/pre]
For more help with Macro programming examples, I recommend the SAS Macro facility documentation. Your best bet to use the SAS Macro facility within a stored process is to:
1) start with a working SAS program that produces both the outputs (or all the outputs) you want;
2) modify the program in #1 to use hard-coded %LET statements and make sure that you have the right set of macro variables to generate all your alternate outputs;
3) put the program from #2 into a SAS Macro program and include conditional logic -- test your program with all the possible values of the macro variables that your users will be able to send. Make sure that all outputs are the correct output. At this point, using SYMBOLGEN, MPRINT and MLOGIC options will help you debug your macro program logic.
4) FINALLY, turn the program from #3 into a stored process. Up until this step, you have NOT been running code as a stored process. You are doing all your development for #1, #2 and #3 in an EG code node or in SAS Display Manager.
For help with specific macro programming tasks, your best bet is to contact SAS Technical Support.
cynthia