1         Macro

 

 

1.1       Re-use existing macro

 

/*example*/

/*say you have two macros under such direction*/

 

filename test 'J:\OCC_DATA\Zunqiu(Eric)\SAS macro\sas Code';

filename sample 'J:\OCC_DATA\Zunqiu(Eric)\SAS macro\sas Code';

 

options mautosource mautolocdisplay sasautos=(test sample  sasautos);

 

 

proc options option=sasautos;run;

%test;

libname books "J:\OCC_DATA\Zunqiu(Eric)\SAS macro\dataset";

%sample(books.Ytdsales);

 

/* here is the two macros code: test and sample*/

/*Test.sas is the macro name*/

%macro test;

            %put hello;

%mend;

 

/*sample.sas is another macro name*/

%macro sample(dsname);

%if %sysfunc(exist(&dsname)) %then %do;

proc print data=&dsname(obs=10);

title "First 10 Observations of &dsname";

run;

%end;

%else %put ERROR: ***** Data set &dsname does not exist.;

%mend sample;