I feel very close to solving this issue on my own... My guess is it has to do with mismatching variable types? I'm trying to get my code to produce two tables called 'recentAB' and 'recentAC'. (In actual practice, my programlist will be much, much longer, but all substrings of it will have hyphens that I want to not appear in the titles of the datasets.) %let programlist = A-B A-C;
%macro testloop;
%local i ithprogram nodash;
proc sql;
%do i = 1 %to %sysfunc(countw(&programlist, ' '));
%let ithprogram = %scan(&programlist, &i, ' ');
%let nodash = compress(&ithprogram, '-');
create table recent_&nodash as
select distinct t1.id,
t1.yeardate,
t1.program,
from libraryname.dataset t1
where t1.yeardate >= "2018" and t1.program = "&ithprogram"
order by t1.yeardate,
t1.id;
%end;
quit;
%mend;
%testloop; I colored the text (in green) where I'm pretty sure my error is occurring. If I were to replace that part with create table recent&i as Then the tables 'recent1' and 'recent2' get created (with their contents correctly filtered)... So I'm not sure why recent&i works when recent&nodash does not? Reason I think it is a type mismatch is that I get ERROR 22-322 when I try running my code.
... View more