Hello, I am trying to create a list of table names so that I can make a do-until loop that goes through each table and creates a new table that separates specific years into new tables. The imports work, the list works, and both proc sqls work until I added the do until loop. My goal is: for every table, create a new table by year until there are no more tables left to iterate. This is what I have so far: (There probably is a better way to make a list for the existing tables, but with the name it should still work). data work.tables; input table_name $; cards; data1 data2 data3 ; run; proc sql; select distinct table_name into: table_list separated by ',' from tables; quit; %macro loop(current_table_list = table_list, obs = 3); %local i next_table; %let i=1; %let next_table = %scan(¤t_table_list, &i, %str()); %do %until(%superq(next_table) eq %str()); proc sql; select distinct put(year, 4.) into :yearList separated by ',' from &next_table. where year >= 1940 and year <= 1980; quit; %let column = put(year, 4.); %let table = work.&next_table.; proc sql noprint; select distinct cat("DATA year_", &next_table., compress(&column.,,'kad'), "; set &table. (where=(&column.='", &column., "')); run;") length = 500 into :allsteps separated by ';' from &table. where year >= 1940 and year <= 1980; quit; &allsteps.; %let i = %eval(&i + 1); %let next_table = %scan(¤t_table_list, &i, %str()); %end; %mend; This is the output I get OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK; No output or results.
... View more