Leading principle: Avoid potential conflicts when using the library - Don’t use common names - Don’t change options permanently
Example at start of macro:
* Get original option for displaying 262 character warnings and turn it off for the duration of the macro;
%let original_quotelenmax_value = %sysfunc( getoption(quotelenmax) );
option noquotelenmax;
And then at end of macro:
* Turn options back to original value;
option &original_quotelenmax_value.;
alima-
or alima_
tempvar
within Stata for temporary variable namesBefore main part of macro:
%let work_path=%sysfunc(pathname(work));
%let original_dlcreatedir_value = %sysfunc( getoption(dlcreatedir) );
option dlcreatedir;
libname macdir "&work_path/this-macro-name";
Before end of macro (the library can be left when debug is on):
libname macdir clear;
option &original_dlcreatedir_value;
%global
and %local
especially within macros, SAS - Scopes of Macro Variableslocal
and global
in def