Here's some of what I've been doing recently. (Big caveat: all of this is from memory since
I haven't coded a single line of SAS for more than three months now).
The basic idea is to modularize the code which allows to execute parts of it conditionally.
So my code usually looks somewhat like
[pre]
%include ddname(member1) ;
%include ddname(member2) ;
%include ddname(member3) ;
[/pre]
By putting an asterisk in front of "%include" parts of the code can be deactivated.
SAS's idiosyncratic way of interpreting, compiling, executing the program code allows
to make this process dynamic.
So back to some sample code
[pre]
... some code that executes unconditionally ...
/* macro variables can be created/modified in open code */
/* where 'open code' means that the statements are not */
/* embedded in a data/proc step nor in a macro routine either */
%let dsname = THE.MVS.DATASET.NAME ;
%let _catlgd = %sysfunc(dsncatlgd("&dsname")) ; /* returns 0 or 1 */
%let _filexist = %sysfunc(fileexist("&dsname")) ; /* returns 0 or 1 */
/* function DSNCATLGD has the advantage of not allocating the dataset */
/* dynamically. Instead it does a catalog lookup. */
/* Choose whichever function is more appropriate for your case. */
/* now we use these values to extract either a blank or an asterisk */
/* from %str(* ) */
%let _asterisk1 = %sysfunc(substr(%str(* ),%eval(&_catlgd +1),1)) ;
%let _asterisk2 = %sysfunc(substr(%str(* ),%eval(&_filexist+1),1)) ;
/* as a result &_asterisk determines whether the next statement */
/* will be interpreted as a comment statement or an executable statement */
/* i.e. whether member "member" will be included or not */
&_asterisk1%include ddname(member) ; /* member being included conditionally */
... some more code that executes unconditionally ...
[/pre]
Hope this helps. Or at least gives you some ideas.
And of course, I'm not using long variable names like &_asterisk in my programs.
... View more