03-18-2015 12:42 PM
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)
03-18-2015 02:57 PM
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.
03-19-2015 04:58 AM
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?
03-19-2015 09:00 AM
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
03-20-2015 02:10 PM
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;
43 filename mylib "/folders/myfolders/myautocall";
45 options mautosource sasautos=(mylib sasautos) mautolocdisplay;
WARNING: Apparent invocation of macro PARCRECH not resolved.
47 %PARCRECH(8000, Dec, '/folders/myfolders/files/rechareg_echantillon_janvier.txt')
ERROR 180-322: Statement is not valid or it is used out of proper order.
03-20-2015 05:19 PM
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;
03-20-2015 06:37 PM
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'));
03-20-2015 07:19 PM
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: