Change history_%i.dta
to `history_&i..dta'.
%macro exporthistory;
%do i = 0 %to 9;
proc export data = a.history&i outfile = "LOCATION/history_&i..dta";
run;
%end;
%mend exporthistory;
%exporthistory;
Ampersand ("&") is the macro variable delimiter, as you correctly use earlier. Also, you need a second period as &i.
is the macro variable, and the second period is part of the filename.