Thanks Astounding! I certainly had over-cooked this one. I'm interested in your comment that there may be a more efficient way to approach this problem without running multiple data steps. What I actually have is a long dataset with an id variable (hrno), three variables which are search terms (ssub1 ssub2 ssub3) and a fourth variable which is a classifier (nht). In a second dataset, I am searching the field addr for either ssub1 or (ssub2 and ssub3). If I identify that a row in the second dataset satisfies a search term, I want to update the category field with the value of the classifier. Originally I was coding all the search terms into a datastep manually but decided this would be much better approached using a macro. I haven't had a large amount of experience with macros so this was all I could come up with. I hadn't written the whole macro yet but was just testing to make sure I could get the macro loop to work with one search term before continuing. As I mentioned in my reply to Kurt, the loop doesn't seem to be iterating as I expected anyway so definitely open to other suggestions. Thanks very much!! So far my code is: %macro addrclass;
%do i = 1 %to &max.;
proc sql noprint;
select ssub1var, ssub2var, ssub3var, nhtvar
into :ssub1, :ssub2, :ssub3, :snht
from hrlist
where hrno=&i;
quit;
%put &i. &ssub1. &ssub2. &ssub3. &snht.;
data class;
set class;
if find(addr,"&ssub1.")>0 then flag=1;
run;
%end;
%mend;
... View more