This macro will search each directory listed in the SASAUTOS option, looking for the macro name that was passed in as a parameter. If the macro is found, a message is printed to the log giving the location of the macro.
This sample uses a function called COUNTW which was made available starting with SAS 9.1. This sample will not work prior to SAS 9.1.
See sample 26152 for an alternative to the COUNTW function:
Sample 26152: Retrieving the number of words in a macro variable
These sample files and code examples are provided by SAS Institute Inc. "as is" without warranty of any kind, either express or implied, including but not limited to the implied warranties of merchantability and fitness for a particular purpose. Recipients acknowledge and agree that SAS Institute shall not be liable for any damages whatsoever arising out of their use of this material. In addition, SAS Institute will provide no support for the materials contained herein.
%macro drive(mac);
%let list=%sysfunc(getoption(sasautos)) %sysfunc(pathname(sasautos));
%let final_list=%sysfunc(tranwrd(%qsysfunc(compress(%bquote(&list),())),' ',','));
%let word_cnt=%sysfunc(countw(%bquote(&final_list),%str(,)));
%do i = 1 %to &word_cnt;
%let path=%sysfunc(tranwrd(%upcase(%sysfunc(compress(%scan(%bquote(&final_list),&i,%str(,)),
%str(%')))),SASAUTOS,%str()));
/** Backslash would need to change if running on OS other than Windows **/
%if %sysfunc(fileexist(&path\&mac..sas)) %then %do;
%put macro &mac was found in &path;
%end;
%end;
%mend drive;
/** Replace trim with the macro you are looking for **/
/** This sample will return the location of the trim macro **/
%drive(trim)
These sample files and code examples are provided by SAS Institute Inc. "as is" without warranty of any kind, either express or implied, including but not limited to the implied warranties of merchantability and fitness for a particular purpose. Recipients acknowledge and agree that SAS Institute shall not be liable for any damages whatsoever arising out of their use of this material. In addition, SAS Institute will provide no support for the materials contained herein.
/** LOG results **/ macro trim was found in C:\PROGRAM FILES\SAS\SAS 9.1\CORE\SASMACRO
Type: | Sample |
Topic: | SAS Reference ==> Macro |
Date Modified: | 2010-12-13 10:59:35 |
Date Created: | 2009-11-13 11:50:08 |
Product Family | Product | Host | SAS Release | |
Starting | Ending | |||
SAS System | Base SAS | Microsoft Windows NT Workstation | ||
Microsoft Windows 2000 Advanced Server | ||||
Microsoft Windows 2000 Datacenter Server | ||||
Microsoft Windows 2000 Server | ||||
Microsoft Windows 2000 Professional | ||||
Microsoft Windows 7 | ||||
Microsoft Windows 95/98 | ||||
Microsoft® Windows® for x64 | ||||
OS/2 | ||||
Microsoft Windows XP 64-bit Edition | ||||
Microsoft Windows Server 2003 Datacenter 64-bit Edition | ||||
Microsoft Windows Server 2003 Enterprise 64-bit Edition | ||||
Microsoft® Windows® for 64-Bit Itanium-based Systems | ||||
z/OS | ||||
OpenVMS VAX | ||||
Microsoft Windows Server 2003 Datacenter Edition | ||||
Microsoft Windows Server 2003 Enterprise Edition | ||||
Microsoft Windows Server 2003 Standard Edition | ||||
Microsoft Windows Server 2008 | ||||
Microsoft Windows XP Professional | ||||
Windows Millennium Edition (Me) | ||||
Windows Vista | ||||
64-bit Enabled AIX | ||||
64-bit Enabled HP-UX | ||||
64-bit Enabled Solaris | ||||
ABI+ for Intel Architecture | ||||
AIX | ||||
HP-UX | ||||
HP-UX IPF | ||||
IRIX | ||||
Linux | ||||
Linux for x64 | ||||
Linux on Itanium | ||||
OpenVMS Alpha | ||||
OpenVMS on HP Integrity | ||||
Solaris | ||||
Solaris for x64 | ||||
Tru64 UNIX |