05-14-2012 02:55 PM
Hi, I have a question about how to use customer-defined macros stored in a local directory. I learn that there are two methods: specify the "autocall macro libraries" or use %include to inclue an external file. Both of them look easy. However, I have no problem with the second method, but never worked the first out.
I saved some written macros as .sas file in a directory. For example, in the directory D:\work\sasfiles, there is a file named xxx.sas. Inside the file, there is just a simple macro defined:
I then write the following lines in the main program :
options sasautos=("D:\work\sasfiles" sasautos);
As long as I run the main progrm, there is an error message: Warning: Apparent invocation of macro xxx not resolved.
However, If I write
The code runs perfectly.
My understanding is that I only need to specify a directory for the auto libraries (sasautos). This is what I want, since I have multiple macros saved in the same directory.
I work with SAS9.2 in a unix enviroment.
Thank you for your help.
05-14-2012 03:29 PM
Since LinLin has answered your question, I will just pick on you a little:
You said: "I learn that there are two methods".
Not quite. There are actually another way to store and run customer-defined macros. You can compile-store and then call the compiled macro to run. comparing to the two methods you mentioned, this is most efficient to run a macro repeatedly (and more secure if you don't want your code being seen by other users). Search SAS help for details.
05-14-2012 03:37 PM
Thanks for the responses. However, it still doesn't work if I remove the word sasautos in the parentness. I did so before, since I don't want to overwrite the default sas auto libraries.
05-14-2012 04:10 PM
I use PC sas.
first I saved the code below at 'C:\TEMP\forum' as plast.sas
proc print data=&syslast;
I call the macro by:
options mautosource sasautos=('C:\TEMP\forum',sasautos);
05-14-2012 04:14 PM
Ben, your code does look correct but ...
You say you are running on Unix. Yet the path in quotes is a path on the PC. Do you have some sort of hybrid environment where the Unix machine can't find the folder? Are you getting any error messages related to the OPTIONS statement?
05-14-2012 04:20 PM
You may have to try something like this on Unix:
options sasautos=('/my/unix/directory', '!SASROOT/sasautos');
...or try assigning it to a FILENAME first:
filename mylib "d:\work\sasfiles\xxx.sas";
options sasautos=(sasautos, mylib);
I'm not sure if the order maters, but I always specify the sasautos fileref first, then a local fileref.
Also...there's a note in the documentation about SASAUTOS not recognizing upper case or mixed case filenames in Unix.
05-14-2012 11:42 PM
first code: and save it.
%let USER_UMACRO_PATH =F:\Community_SAS;
options sasautos=("&USER_UMACRO_PATH" %sysfunc(getoption(SASAUTOS)));
Second go to sasv9.cfg file and add you autocall library path(see the last line i have modified):
-SET SASAUTOS (
Now close sas editor and reopen the new one and check by invoking the macro...
Hope it helps..