I'm not sure that I understand what you want the macro for, but I think you want to use the RENAME subroutine to rename the files in PROC IML. You can't call PROC DATASETS from your PROC IML program. (You can do it in SAS/IML Studio, but that's not what you asked.)
Without worrying about macros, here's how you can rename functions in PROC IML. Hopefully, this will give you the information you need.
proc iml;
x=1;
create d1 var {x}; append; close; /** create fakes data sets **/
create d2 var {x}; append; close;
create d3 var {x}; append; close;
oldIdx = {1 2 3}; /** old indices **/
newIdx = {4 5 6};/** new indices **/
do j = 1 to ncol(newIdx);
oldName = "d" + strip(char(oldIdx[ j ]));
newName = "d" + strip(char(newIdx[ j ]));
call rename(oldName, newName);
end;
ds = datasets(work);
print ds;
Incidentally, you can't use the indices in your example ({1,2,3} ==> {3,5,7}) because you'll end up trying to rename data1 to data3, which already exists.