Hi, i have two questions, would you help me please :
1/ I create my first macro in sas and i m asking how to save it as executable.
2/ how to combine between sas enterprise quide and sas/af ?
(i'm working on sas enterprise quide 4.3)
I find the easiest way to manage SAS macros is to put them in an AUTOCALL library: SAS(R) 9.3 Macro Language: Reference
When you call the AUTOCALL macro in your SAS program, SAS will automatically search for it, run the macro to define then run your call of it - it does not need to be run in advance.
AUTOCALL macros will work fine in EG or in a SAS/AF submit block.
Thank you SASKiwi. Do you know how I can find the autocall library in the enterprise server (in wich sas is installed) because i m not working on my laptop?
proc options option=sasautos;run;
libname sasautos list;
But you can extend this search path with:
libname mylib 'C:\temp';
options sasautos=(mylib, sasautos);
Now you can save a macro called %myfirstmacro with a file name: C:\temp\myfirstmacro.sas
Hi Gergely,
that's what i used:
filename mylib "/folders/myfolders/myautocall";
options mautosource sasautos=(mylib sasautos) mautolocdisplay;
%PARCRECH(8000, Dec, '/folders/myfolders/files/file.txt')
and it displays this:
1 OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
42 ;
43 filename mylib "/folders/myfolders/myautocall";
44
45 options mautosource sasautos=(mylib sasautos) mautolocdisplay;
WARNING: Apparent invocation of macro PARCRECH not resolved.
46
47 %PARCRECH(8000, Dec, '/folders/myfolders/files/rechareg_echantillon_janvier.txt')
_
180
ERROR 180-322: Statement is not valid or it is used out of proper order.
Your code looks fine.
1. Your file (where the macro is saved) is called parcrech.sas (lowcase!)?
2. The file should contain only the macro definition.
3. Make sure the macro has 3 parameters (as in the call of the macro).
4. When you make a failed attempt to auto-load the macro, restart your SAS session. Otherwise it will not try to find it again. Or use: options mrecall;
It may not hurt to expand on Gergely rule 2: First thing in the source file: %macro PARCRECH (<parameters>);
You may also need to invoke it as:
%PARCRECH(8000, Dec,%str( '/folders/myfolders/files/rechareg_echantillon_janvier.txt'));
thanks Gergely, the was called "ParcRech.sas".
thank you
It looks like your SAS runs on Unix. In that case ALL autocall macro program names must be in lower case otherwise they wont be recognised:
33772 - Names of autocall macro .sas files must be lowercase in the UNIX environment
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.