Given your original program, the simplest fix would be to change this statement:
x=dates.&i;
Turn that into:
%let x = &&dates&i;
Then immediately (don't wait until after the %DO loop, and certainly don't wait for a different macro) add the macro call that should run for each date, referring to &X as needed.
... View more