When it comes to getting lists of table names then you might consider the Dictionary tables, especially if the objective is to work with "every set" in a library.
You get the library name and data set name similar to
Proc sql;
create table setnames as
select libname, memname
from dictionary.tables
where libname='MYLIB' and memtype='Data'
;
run;
You should investigate CALL EXECUTE to write code with stuff in a data set. You use the variable names holding the bit to write the syntax. Call Execute places code into stack that executes after a data step ends. That is basically what your
select distinct
cat("DATA year_", &next_table., compress(&column.,,'kad'), "; set &table.
(where=(&column.='", &column., "')); run;")
does if I understand what you are attempting.
I suspect that you have a problem here:
(where=(&column.='", &column., "'))
If &column is put(year, 4.) . The macro definition means that is the text
then the above resolves to
(where=(put(year,4.)='", &column., "'))
and even a later resolution of &column is going to quotes, commas and spaces and so is very unlikely to ever result in the Where returning anything.
Once you have set candidate years instead of writing a bunch of where dataset option data steps, that will require reading each record from each data set multiple times you would be better off, if this is really needed, to write one data step that look something like
data table1940
table1941
table1942
...
table1980;
set table;
select year;
when(1940) output table1940;
when(1941) output table1941;
when(1942) output table1942;
...
when(1980) output table1980;
otherwise;
end;
run;
I have a very hard time seeing where creating all of these data sets is an advantage.
... View more