BookmarkSubscribeRSS Feed
orangejuss
Fluorite | Level 6

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;

3 REPLIES 3
PeterClemmensen
Tourmaline | Level 20

Yes. But how do you know what filters to apply when?

andreas_lds
Jade | Level 19

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.

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

What is Bayesian Analysis?

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 3 replies
  • 600 views
  • 2 likes
  • 3 in conversation