This tutorial explains how to store macros in a location and call them from the location.
3 Types of Macro Library
- % Include
- Autocall Macro Facility
- Stored Compiled Macro
Store macros in a location and call it from the location using %Include.
%include "C:\Users\Deepanshu\Downloads\storemacroval.sas"; %storemacroval;
In the program above, the directory contains macro and %storemacroval is a name of macro.
Disadvantage : You have to mention file name of the macros.
The name of the file must be the same as the macro name. For eg. the file that contains '%storemacroval' macro must be named as 'storemacroval.sas'. On the UNIX OS, the name of the file that stores the macro definition must be in all lowercase characters.
options mautolocdisplay mautosource sasautos = ("C:\Users\Deepanshu\Downloads\"); %storemacroval;
In the program above, the directory contains individual files. Each file contains one macro definition.
Step I : Storing the macro
In the macro code, add the following lines.
libname loct "C:\Users\Deepanshu\Downloads\"; options mstored sasmstore = loct; %macro storemacroval / store source des="Description of Macro";
Step II : Using Stored Compiled Macros
libname loct "C:\Users\Deepanshu\Downloads\"; options mstored sasmstore = loct; %storemacroval;
libname loct "C:\Users\Deepanshu\Downloads\"; PROC CATALOG catalog=loct.sasmacr; Contents; Run;
proc sql; select * from dictionary.catalogs where memname in ('sasmacr'); quit;
I was thinking from yesterday if you could post something about autocall sas macro and Its miracle today you posted it/
ReplyDeleteAwesome. Cheers!
DeleteCan you recommend some good books for Statistics in SAS or R language ?
ReplyDeleteCheck out this link - Statistics with SAS and R
DeleteHi Deepanshu,
ReplyDeleteThanks for writing on SAS Macro library.
Could you please also try to explain more on the usage of sas macro library.
e.g. in what situation it is ideal to use sas macro library rather then writing sas macros within the code itself.
Thanks.
Could you explain about the cdisc,sdtm,adam like above questions
ReplyDelete