%macro renameloop(oldprefix=X,newprefix=Y, oldstart=1,newstart=1,count=1); %local i; %do i=1 %to &count; &oldprefix%eval(&oldstart+&i-1) = &newprefix%eval(&newstart+&i-1) %end; %mend renameloop; proc sort data=sashelp.pricedata out=pricedata nodupkey; by Date; run; %let renames=%renameloop(oldprefix=Price,newprefix=UnitPriceProduct,count=17); options symbolgen; data Prices2002; set pricedata; where Date between "01jan2002"d and "30jun2002"d; rename &renames ; run; options nosymbolgen; proc print data=Prices2002 heading=h; id Date; format Date date9.; var UnitPrice:; title1 "Product Prices throughout First Half of 2002"; run;