The abuse of the so-called "macro variable arrays" like this should be avoided. There is no need for them in this context and they are not used correctly (they should be %local^ed to the macro at the least.) Here is an alternative using the vcolumn sashelp view that is associated with the similarly named dictionary table. This will error if there exist variables like x, y1, y2,... already in the new dataset. Hope this helps a bit.
[pre]
/* test data with five vars and one obs */
data one;
retain U V _X Y Z .;
run;
/* making a copy */
data two;
set one;
run;
%*-- first var to x, the rest to y2, y3, ... --*;
%macro renameXY(data);
%local d1 d2 libname memname where ds rc name varnum;
%if not %sysfunc(exist(&data)) %then %return;
%let d1 = %scan(&data,1,.);
%let d2 = %scan(&data,2,.);
%let libname = %upcase(%sysfunc(ifc(&d2=,work,&d1)));
%let memname = %upcase(%sysfunc(ifc(&d2=,&d1,&d2)));
%let where = (libname="&libname" and memname="&memname");
%let ds = %sysfunc(open(sashelp.vcolumn(where=&where),is));
%syscall set(ds);
%do %while (%sysfunc(fetch(&ds))=0);
%if &varnum=1 %then %sysfunc(catx(=,&name,x));
%else %sysfunc(catx(=,&name,y&varnum));
%end;
%let rc=%sysfunc(close(&ds));
%mend renameXY;
proc datasets lib=work;
modify two;
rename %renameXY(one);
run;
quit;
/* check */
proc contents data=two;
run;
/* on lst -- in part
# Variable Type Len
1 x Num 8
2 y2 Num 8
3 y3 Num 8
4 y4 Num 8
5 y5 Num 8
*/
[/pre]