Skip to content

Instantly share code, notes, and snippets.

@statgeek
Last active August 11, 2020 15:46
Show Gist options
  • Save statgeek/ba360dd1cf748bf6d0da7e2e16aafe66 to your computer and use it in GitHub Desktop.
Save statgeek/ba360dd1cf748bf6d0da7e2e16aafe66 to your computer and use it in GitHub Desktop.
SAS Rename - proc datasets
/*This code illustrates how to rename data sets dynamically*/
data _new_list;
set sashelp.vtable
(where=(upcase(libname)='WORK')) end=eof;
*filter list for only tables of interest;
*start proc datasets;
if _n_=1 then
call execute ('proc datasets lib=WORK nodetails nolist; change');
*add on new name calculation;
new_name=catt('Name', put(_n_, z3.));
*pass new and old name to proc datasets;
call execute (memname);
call execute ('=');
call execute (new_name);
*if last record then quit;
If eof then
call execute (';run;quit;');
run;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment