3
votes

The PATHNAME() and GETOPTION() functions return different results for SASAUTOS, casting doubt on what directories are used for AUTOCALL. Does SASAUTOS exist as two distinct "things" happening to posses the same name?

To provide some background, I maintain a directory for personal utility macros, the path of which has been added to my config file.

-SET SASAUTOS (

        "!SASROOT\core\sasmacro"
        "!SASROOT\aacomp\sasmacro"
        "!SASROOT\accelmva\sasmacro"
        "!SASROOT\assist\sasmacro"
        "!SASROOT\dmscore\sasmacro"
        "!SASROOT\ets\sasmacro"
        "!SASROOT\gis\sasmacro"
        "!SASROOT\graph\sasmacro"
        "!SASROOT\hps\sasmacro"
        "!SASROOT\iml\sasmacro"
        "!SASROOT\or\sasmacro"
        "!SASROOT\qc\sasmacro"
        "!SASROOT\stat\sasmacro"
        "C:\USERS\ME\PERSONAL AUTOCALL"
        )

This behaves as expected. When I load SAS, I can call whatever macros reside in the PERSONAL AUTOCALL directory.

I also run a complex process which requires a multitude of problem specific macros. These reside in a separate directory from my PERSONAL AUTOCALL. Since these macros should be available independent of whomever runs the process, they are not included in the config file. Instead, I have SAS load the directory into the autocall search hierarchy from within the session. I do this by issuing the following statement.

options mautosource mrecall sasautos = (SASAUTOS, 'Z:\Path\To\COMPLEX PROCESS AUTOCALL');

Again, this behaves as expected. When the first argument SASAUTOS is excluded from the options statement, only the COMPLEX PROCESS AUTOCALL macros may be called and vice versa.

The trouble arises when I monitor what directories are in the autocall search hierarchy. To do this, I issue:

%put %sysfunc(pathname(sasautos));

This returns the precise list given in my config file, given above. It lacks the COMPLEX PROCESS AUTOCALL path, despite the SASAUTOS= option having included it and those macros being call-able.

If I instead issue

%put %sysfunc(getoption(sasautos));

then the following is returned.

(SASAUTOS, "'C:\Path\To\COMPLEX PROCESS AUTOCALL'")

While the combination of the two %put statements provide what I believe is a full listing of the autocall libraries, I'm at a loss for why both are needed.

PATHNAME() returns the name of a data library, in this case SASAUTOS which should have been appended with COMPLEX PROCESS AUTOCALL, at least within the context of the current session.

GETOPTION() returns the value of a SAS system option. Apparently the system option is distinct from the data library.

Do the different return values indeed imply that two different SASAUTOS "things" exist, one a library and the other an option? If so, how do they interact? Given this unexpected discrepancy, how can I be sure there aren't other directories being searched than those listed?

1

1 Answers

1
votes

Yes, SASAUTOS is two things here. It is a system option and a fileref. (Note that it is not a library; it's not really significantly different from a library in most ways, but it isn't one. Significantly, you cannot reference SAS datasets in SASAUTOS with normal dot notation.)

The fileref SASAUTOS is created by default from the SASAUTOS option in the config (or options at startup) and sets OPTION SASAUTOS to point to that (and only that) initially. See from the above linked doc page:

SAS automatically generates a fileref named SASAUTOS. This is the default value of the SASAUTOS= option and points to all the SAS autocall macros.

It's important not to mess with that in general because it's used by SAS to locate system macros. You're welcome to add paths to the fileref in the config, but otherwise make sure you don't remove it from the SASAUTOS option.

To do what you're trying to do, I would say you have three choices.

One is to combine GETOPTION with PATHNAME, as you can see; you'd just have to append the results of GETOPTION with the results of PATHNAME. You could automate it, actually; use GETOPTION, and then if any of the results look like filerefs (8 characters or less, no dot or \ or whatever) run PATHNAME on them and append the results.

Two is to remove your personal macro library from the fileref and instead append it in your autoexec. You'd have to be careful then to always append it when appending other libraries, though.

Three is to make a second fileref, and append any additional paths to that fileref. That's nice because you can be sure OPTION SASAUTOS only has two values (fileref SASAUTOS and your MYAUTOS fileref), and then you just have to append your new files to that (use PATHNAME to get the currently-loaded paths, then add to that, then re-define the fileref). That might be the easiest to maintain as long as you're careful to always redefine it properly (create a macro (!) to do this...)

It also has the advantage that other programmers can simply make their own core fileref and the program still works for them (if they have a different macro library), though of course their macro library had better contain the macros needed for the project.