DATA Step, Macro, Functions and more

how to delete an autocall location from SASAUTOS?

Reply
Frequent Contributor
Posts: 91

how to delete an autocall location from SASAUTOS?

SAS folks-

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" ;

options append=sasautos=(U_MACROS);

using

%put %sysfunc(getoption(sasautos));

gives me back

(SASAUTOS U_MACROS)

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" ;

options append=sasautos=(DB_MACS);

to give

(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!

Wendy T.

Super User
Super User
Posts: 6,500

Re: how to delete an autocall location from SASAUTOS?

The easiest solution is to remember the setting before you changed it and then restore it when it no longer applies.

%let save=%sysfunc(getoption(sasautos));

....

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.

%LET REMOVE=SASAUTOS;

%put %sysfunc(getoption(sasautos));

data _null_;

  sasautos = getoption('sasautos');

  i = findw(sasautos,"&remove",'( )','mqri');

  if i then sasautos = substr(sasautos,1,i-1)

                    || substr(sasautos,i+length("&remove"))

  ;

  call execute(catx(' ','options sasautos=',sasautos,';'));

run;

%put %sysfunc(getoption(sasautos));

Super User
Posts: 3,110

Re: how to delete an autocall location from SASAUTOS?

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.

Frequent Contributor
Posts: 91

Re: how to delete an autocall location from SASAUTOS?

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!

Wendy

Super User
Posts: 3,110

Re: how to delete an autocall location from SASAUTOS?

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.

Valued Guide
Posts: 2,175

Re: how to delete an autocall location from SASAUTOS?

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.

peterC

Ask a Question
Discussion stats
  • 5 replies
  • 554 views
  • 6 likes
  • 4 in conversation