07-30-2013 04:29 PM
Recently, I added a directory for general-purpose macros to SASAUTOS in my autoexec file by using the append method from this helpful SAS sample. http://support.sas.com/kb/42/360.html
FILENAME U_MACROS "&utility\utility_macros" ;
gives me back
I also have macros that are applied in different situations - one being a series of programs that extract data from our databases in Oracle. To add that directory, I was thinking of adding
FILENAME DB_MACS "&utility\database_utility_macros" ;
(SASAUTOS U_MACROS DB_MACS)
at the beginning of the code that runs those programs. However, when the database series of programs is over, the DB_MACS macros no longer apply, and I would need to set SASAUTOS back to (SASAUTOS U_MACROS), before going on to the rest of the program run. I've been looking through the documentation, but can't seem to find an option to delete from SASAUTOS.
Your help would be greatly appreciated!
07-30-2013 05:47 PM
The easiest solution is to remember the setting before you changed it and then restore it when it no longer applies.
options sasautos=&save ;
If that is impossible then you can use some logic to find and remove a particular value. But remember that the value could include actual path names in addition to filerefs.
sasautos = getoption('sasautos');
i = findw(sasautos,"&remove",'( )','mqri');
if i then sasautos = substr(sasautos,1,i-1)
call execute(catx(' ','options sasautos=',sasautos,';'));
07-30-2013 05:56 PM
Well one way would be: options sasautos = (SASAUTOS, UMACROS); Even if the DB_MACS no longer apply there would be no harm leaving them in the AUTOCALL definition even if you are not using them.
07-31-2013 11:25 AM
Tom & SASKiwi-
Thanks so much for your replies! I was thinking that I just couldn't find an option that exists. I also thought about using FILENAME DB_MACS CLEAR; I'll have to do some experimentation next week, as this affects my main product runs, and I will have to set up an analog for testing.
SASKiwi- Actually, I can't leave DB_MACS active, as some of the macros have the same names and functions, but use different variable names. I know that's bad form, but I wrote the original macros for my project (in SAS datasets with 'my' variable names), then later generalized them to our Oracle databases, so they can be used for any project. When I'm doing things in Oracle, I have to use nasty variable names like WTR_QUAL_PARAM_NM instead of ANALYTE and MTHD_DTCTN_LMT_VAL instead of MDL, and so forth.
Thanks for your help!
07-31-2013 03:57 PM
In that case just thought it is useful to point out that the search order for AUTOCALL macros is from left to right so if you want your DB_MACS versions to be used in preference to the UMACROS versions then you could specify it like this:
options sasautos = (DB_MACS, UMACROS, SASAUTOS); This has the same effect as the APPEND feature.
08-02-2013 03:38 AM
The INSERT option is similar to APPEND but has the effect of giving priority to the folder of macros that you "insert" , as the folder is INSERTed at the beginning of the SASAUTOS vslue.