I have been going through SAS code written by others, which references a number of macros in folders around a large corporate network and I don't really know what many of these functions do. Is there a way of locating where SAS is finding the code for an individual function.
So if I put in a macro name for example rather than carrying out the instructions of the macro it would tell my the file path to where the code is located.
Thanks
Hi
Have a look the MAUTOLOCDISPLAY SAS System Option.
When you call an autocall macro, it will display the location of the code.
Also have a look at other macro related SAS System Options here http://support.sas.com/documentation/cdl/en/allprodslang/68037/HTML/default/viewer.htm#syntaxByCateg...
Bruno
run PROC OPTIONS and look for SASAUTOS in the log.
It may give you a hint where to search the macro.
Shmuel
Hi
Have a look the MAUTOLOCDISPLAY SAS System Option.
When you call an autocall macro, it will display the location of the code.
Also have a look at other macro related SAS System Options here http://support.sas.com/documentation/cdl/en/allprodslang/68037/HTML/default/viewer.htm#syntaxByCateg...
Bruno
Thanks bruno this seems to work
%let x=%sysfunc(pathname(sasautos)); %put &x ;
If you are using autocall macros I have a program that you can run at the end of your program that will read the list of compiled macros from WORK.SASMACR and try to find corresponding files in the SASAUTOS paths that match the macro names.
So if you can re-run your complicated program and then call this at the end you can get a report of which macros the program called.
For this to work you need to use autocall macros and not stored compiled macro catalogs. Also you need to be careful to define only one macro in each source code file in your autocall library. Also if you have a complicated program with conditional branches it will only find the macros that were actually called. It won't find any that the code might use in branches of the code that did not run.
%macro maclist
/*----------------------------------------------------------------------
Generate list of compiled macros and their source directories
----------------------------------------------------------------------*/
(out=maclist /* Name of dataset to generate */
,dlist= /* Directory list to scan (default=SASAUTOS option) */
);
/*----------------------------------------------------------------------
Produce a summary dataset with the location of the source file for the
compiled macros currently in SASHELP.SASMACR catalog by scanning across
SASAUTOS search path to see if corresponding file exists.
When using SAS 9.2 or higher it will use to Q modifier on the SCAN()
function to allow pathnames to include parentheses when properly quoted.
----------------------------------------------------------------------*/
data &out ;
attrib MACRO length=$32 label='Macro name';
attrib FOUND length=3 label='Found? (0/1)';
attrib FILE length=$36 label='Filename';
attrib DNAME length=$200 label='Directory name';
keep macro found file dname;
if _n_=1 then do;
*----------------------------------------------------------------------;
* Get SASAUTOS option into string variable and copy individual paths ;
* into DLIST, expanding any filerefs that are found (such as SASAUTOS).;
*----------------------------------------------------------------------;
length dlist autos path $32767 ;
retain dlist ;
%if %length(&dlist) %then %do;
autos=%sysfunc(quote(&dlist));
%end;
%else %do;
autos=getoption('sasautos');
%end;
do i=1 by 1 until (path= ' ');
%if %sysevalf(9.2 <= &sysver) %then %do;
path=scan(autos,i,'( )','q');
%end;
%else %do;
path=scan(autos,i,'( )');
%end;
if length(path) <= 8 then do;
if 0=fileref(path) then path=pathname(path) ;
end;
dlist=left(trim(dlist)||' '||path);
end;
end;
set sashelp.vcatalg;
where libname='WORK' and memname='SASMACR'
and memtype='CATALOG' and objtype='MACRO';
macro=objname;
file=lowcase(trim(macro))||'.sas';
*----------------------------------------------------------------------;
* Scan through the paths in DLIST until file found or end of list ;
*----------------------------------------------------------------------;
found=0;
done=0;
do i=1 by 1 until (found or done);
%if %sysevalf(9.2 <= &sysver) %then %do;
dname=dequote(scan(dlist,i,'( )','q'));
%end;
%else %do;
dname=dequote(scan(dlist,i,'( )'));
%end;
if dname=' ' then done=1;
else if fileexist(trim(dname)||'/'||trim(file)) then found=1;
end;
if ^found then dname=' ';
run;
%mend maclist;
Hi
Also have a look at the MAUTOLOCINDES SAS System Option.
Here is what the doc says:
Specifies whether the macro processor prepends the full pathname of the autocall source file to the description field of the catalog entry of compiled autocall macro definition in the Work.SASMacr catalog.
Bruno
Thanks for the program Tom it'd be good to run on large programs.
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.
Ready to level-up your skills? Choose your own adventure.