Firstly, you appear to be mixing SAS macro language constucts (the %LET macro variable assignments) with DATA step logic -- the SAS %LET statement will be resolved at SAS compile time, not with each iterative DATA step pass. Or possibly you are not sharing all SAS code, maybe, such as the surrounding %MACRO and %MEND statements necessary with a %DO %END looping technique.
Recommending reading up on the SAS MACRO facility documentation if you intend to execute your DATA step "n" times, once for each INFILE specification. Also, I noticed you may be intending to read several input files in a single DATA step execution -- which is quite possible, however you will either need to reset your lastobs variable to zero with each DO UNTIL(lastobs); END; execution -- SAS will not reset the variable for you -- another suitable technique is to change your END= SAS variable to make it unique for each %DO %END macro execution.
Scott Barry
SBBWorks, Inc.