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.
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.