<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Read filter from a table sas macro in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Read-filter-from-a-table-sas-macro/m-p/719848#M80197</link>
    <description>&lt;P&gt;Maybe something like&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data filter;
   length source $ 42 filter $ 100;
   infile datalines delimiter='#' dsd;
   input source filter;
   datalines;
sashelp.class#11 &amp;lt;= Age &amp;lt;= 13
;


data _null_;
   set filter;

   call execute(catx(' ', 'proc print data=', source, 'label;'));
   call execute(catx(' ', 'where', filter, ';'));
   call execute('run;');
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;If you want to create datasets, then you should add a variable to "filter" naming the new dataset.&lt;/P&gt;</description>
    <pubDate>Wed, 17 Feb 2021 10:31:36 GMT</pubDate>
    <dc:creator>andreas_lds</dc:creator>
    <dc:date>2021-02-17T10:31:36Z</dc:date>
    <item>
      <title>Read filter from a table sas macro</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Read-filter-from-a-table-sas-macro/m-p/719829#M80194</link>
      <description>&lt;P&gt;Is it possible to read code block from a table and create a data by using these code blocks as a filter?&lt;/P&gt;&lt;P&gt;Thanks in advance.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data filter_data;&lt;BR /&gt;input table_name $6. filter $30. ;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;DATALINES;&lt;BR /&gt;Table1 Count&amp;gt;=3 and date="03feb2021"d&lt;BR /&gt;Table2 sum&amp;gt;=100 and count&amp;lt;50&lt;BR /&gt;;&lt;BR /&gt;RUN;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;%macro create(table,filter);&lt;/P&gt;&lt;P&gt;proc sql;&lt;BR /&gt;create &amp;amp;table. as select&lt;BR /&gt;id,&lt;/P&gt;&lt;P&gt;count(distinct x) as x,&lt;BR /&gt;sum(y) as y,&lt;BR /&gt;count(z) as z&lt;BR /&gt;from sample&lt;BR /&gt;where &amp;amp;filter.&amp;nbsp; /* %put &amp;amp;filter */&lt;BR /&gt;group by id;&lt;BR /&gt;quit;&lt;/P&gt;&lt;P&gt;%mend;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data _null_;&lt;BR /&gt;set filter_data;&lt;BR /&gt;CALL EXECUTE("%create("||table_name||","||filter||");");&lt;BR /&gt;run;&lt;/P&gt;</description>
      <pubDate>Wed, 17 Feb 2021 09:07:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Read-filter-from-a-table-sas-macro/m-p/719829#M80194</guid>
      <dc:creator>orangejuss</dc:creator>
      <dc:date>2021-02-17T09:07:55Z</dc:date>
    </item>
    <item>
      <title>Re: Read filter from a table sas macro</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Read-filter-from-a-table-sas-macro/m-p/719833#M80195</link>
      <description>&lt;P&gt;Yes. But how do you know what filters to apply when?&lt;/P&gt;</description>
      <pubDate>Wed, 17 Feb 2021 09:12:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Read-filter-from-a-table-sas-macro/m-p/719833#M80195</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2021-02-17T09:12:33Z</dc:date>
    </item>
    <item>
      <title>Re: Read filter from a table sas macro</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Read-filter-from-a-table-sas-macro/m-p/719836#M80196</link>
      <description>&lt;P&gt;Some different approaches are presented in the thread&amp;nbsp;&lt;SPAN&gt;&lt;A href="https://communities.sas.com/t5/SAS-Programming/How-to-do-a-dynamic-condition-based-on-variable-value/m-p/589553#M168648" target="_self"&gt;How to do a dynamic condition based on variable value&lt;/A&gt;.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 17 Feb 2021 09:14:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Read-filter-from-a-table-sas-macro/m-p/719836#M80196</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2021-02-17T09:14:33Z</dc:date>
    </item>
    <item>
      <title>Re: Read filter from a table sas macro</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Read-filter-from-a-table-sas-macro/m-p/719848#M80197</link>
      <description>&lt;P&gt;Maybe something like&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data filter;
   length source $ 42 filter $ 100;
   infile datalines delimiter='#' dsd;
   input source filter;
   datalines;
sashelp.class#11 &amp;lt;= Age &amp;lt;= 13
;


data _null_;
   set filter;

   call execute(catx(' ', 'proc print data=', source, 'label;'));
   call execute(catx(' ', 'where', filter, ';'));
   call execute('run;');
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;If you want to create datasets, then you should add a variable to "filter" naming the new dataset.&lt;/P&gt;</description>
      <pubDate>Wed, 17 Feb 2021 10:31:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Read-filter-from-a-table-sas-macro/m-p/719848#M80197</guid>
      <dc:creator>andreas_lds</dc:creator>
      <dc:date>2021-02-17T10:31:36Z</dc:date>
    </item>
  </channel>
</rss>

