Is it possible to read code block from a table and create a data by using these code blocks as a filter?
Thanks in advance.
data filter_data;
input table_name $6. filter $30. ;
DATALINES;
Table1 Count>=3 and date="03feb2021"d
Table2 sum>=100 and count<50
;
RUN;
%macro create(table,filter);
proc sql;
create &table. as select
id,
count(distinct x) as x,
sum(y) as y,
count(z) as z
from sample
where &filter. /* %put &filter */
group by id;
quit;
%mend;
data _null_;
set filter_data;
CALL EXECUTE("%create("||table_name||","||filter||");");
run;
Yes. But how do you know what filters to apply when?
Some different approaches are presented in the thread How to do a dynamic condition based on variable value.
Maybe something like
data filter;
length source $ 42 filter $ 100;
infile datalines delimiter='#' dsd;
input source filter;
datalines;
sashelp.class#11 <= Age <= 13
;
data _null_;
set filter;
call execute(catx(' ', 'proc print data=', source, 'label;'));
call execute(catx(' ', 'where', filter, ';'));
call execute('run;');
run;
If you want to create datasets, then you should add a variable to "filter" naming the new dataset.
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and save with the early bird rate—just $795!
Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.