I want to rename 276 variables. The old names are nL1-nL276 and the new name to be recoded to is contained in a macro variable (&L) This is the code I came up with but it only renames nL1 and not the rest of the 275 variables. %macro rename(oldvarlist, newvarlist); %let k=1; %let old = %scan(&oldvarlist, &k); %let new = %scan(&newvarlist, &k); %do %while(("&old" NE "") & ("&new" NE "")); data xx; set xx; rename &old = &new; run; %let k = %eval(&k + 1); %let old = %scan(&oldvarlist, &k); %let new = %scan(&newvarlist, &k); %end; %mend rename; %rename(nL1 - nL276, &L);
... View more