I'm assuming that all you wish to do is subset your original data set based on a range of dates.
The problem (error message) here is that your original data set x.loan does not have a variable i on the data set. The syntax for the data set options that you use on the set statement applies specifically to x.loan. The variable i is actually created in the output data set test.
Two easy solutions come to mind...
You could try changing the where = (period=dhms(i,0,0,0) portion to an if statement in the data step
data test;
set x.loan(keep= period bron loannr ENR where=(bron NE 'FAF'));
do i = &date_from to &date_to;
if period = dhms(i,0,0,0);
output;
end;
run;
But since you say your original data is very large I would probably recommend using the between-and operator on the where = clause.
ie
(keep=period bron loannr ENR where=(datepart(Period) between mdy(07,01,2010) and mdy(12,01,2010) and bron ne "FAF"));
... View more