BookmarkSubscribeRSS Feed
WendyT
Pyrite | Level 9

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.

5 REPLIES 5
Tom
Super User Tom
Super User

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

SASKiwi
PROC Star

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.

WendyT
Pyrite | Level 9

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

SASKiwi
PROC Star

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.

Peter_C
Rhodochrosite | Level 12

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

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 5 replies
  • 2081 views
  • 6 likes
  • 4 in conversation