BookmarkSubscribeRSS Feed
sas_Forum
Calcite | Level 5

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.

3 REPLIES 3
RW9
Diamond | Level 26 RW9
Diamond | Level 26

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;

Kurt_Bremser
Super User

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;

ballardw
Super User

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.

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

How to Concatenate Values

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 3 replies
  • 1118 views
  • 6 likes
  • 4 in conversation