Skip to content

Instantly share code, notes, and snippets.

@joosti
Last active August 29, 2015 14:10
Show Gist options
  • Select an option

  • Save joosti/5e1c20df74dbba6b2d17 to your computer and use it in GitHub Desktop.

Select an option

Save joosti/5e1c20df74dbba6b2d17 to your computer and use it in GitHub Desktop.
SAS proc datasets macros
/*
libInfo - info on datasets in library
libInfo (lib=, dset=, attr=, eng=, vars=)
lib: library, default is work
dset: dataset, default is _all_
attr: output dataset with attributes, default is work.attr
eng: output dataset with engine, default is work.eng
vars: output dataset with variables, default is work.vars
sample usage: %libInfo(lib=crsp, dset=CCMXPF_LINKTABLE);
*/
%macro libInfo(lib=work, dset=_all_, attr=attr, eng=eng, vars=vars);
ods listing close;
ods output
attributes = &attr
enginehost = &eng
variables = &vars;
proc datasets lib = &lib; contents data=&dset ; quit;run;
ods output close;
ods listing;
%mend;
/*
rm: removes datasets
rm (dsets=, lib=) -- removes dsets in library lib
dsets: datasets to remove
lib: library, default is work
sample usage: %rm(attr eng); * deletes attr and eng from lib work
*/
%macro rm(dsets, lib=work);
proc datasets library=&lib;
delete &dsets;
quit;run;
%mend;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment