1. What are Auto call Macro how to create them?
2. How to create Macro in Global symbol table within Macro parameter?
3. In a sas session i am having 5 libraries currently i have common dataset CITY (Dset name) i wnat to kill this dataset from all the libraries at once.As in future the no of lib may increase and decrease ased on that session.
4. Create a table from one library with all datasets with data.
Hi,
1) They are macro you use all the time, stored in a specific directory, and then used via options sasautos= option, e.g.
libname myautos "c:\myautos";
options sasautos=(myautos);
Just means you don't need to explicitly %include the files.
2) Not sure what you mean here, macros defined with %let, call symput etc. See the documentation on Scope:
http://support.sas.com/documentation/cdl/en/mcrolref/61885/HTML/default/viewer.htm#a000206835.htm
3) Call execute or macro loop:
data _null_;
set sashelp.vlibnam (where=(substr(LIBNAME1,5)="MY_ID"));
/* Note I have assumed all libraries will be prefixed with MY_ID, change to your scenario */
call execute('proc datasets library='||strip(libname)||' nolist; delete city; quit;');
run;
4) Please clarify what you mean, do you just want new_libname to be a copy? Then:
libname NEW_DATA "...";
data _null_;
set sashelp.vtable (where=(libname="OLD_DATA"));
call execute('data NEW_DATA.'||strip(NAME)||'; set OLD_DATA.'||strip(NAME)||'; run;');
run;
1. SAS(R) 9.2 Macro Language: Reference
2. %global variablename;
3.:
data _null_;
do lib_name = 'lib1','lib2',....,'libn';
call execute("proc delete data=" !! strip(lib_name) !! ".city;run;");
end;
run;
Alternatively, you could store your libnames in a dataset and iterate through that.
4.:
proc sql;
select * from dictionary.tables where libname='libname';
quit;
One additional bit about autocall macros: the SAS filename has to match the name of the macro called and best is to only have the code for the macro plus comments in that file.
Don't miss out on SAS Innovate - Register now for the FREE Livestream!
Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.
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.