<?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: How do I search multiple tables output when find condition in SAS Enterprise Guide</title>
    <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-do-I-search-multiple-tables-output-when-find-condition/m-p/737235#M38703</link>
    <description>Looking to have a separate output for each table with all the rows and fields.</description>
    <pubDate>Tue, 27 Apr 2021 12:25:02 GMT</pubDate>
    <dc:creator>cad88</dc:creator>
    <dc:date>2021-04-27T12:25:02Z</dc:date>
    <item>
      <title>How do I search multiple tables output when find condition</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-do-I-search-multiple-tables-output-when-find-condition/m-p/736666#M38681</link>
      <description>Hello,&lt;BR /&gt;&lt;BR /&gt;I have a library that contains tables that start with o_ and some that don't. I want to be able to search through the o_ tables for a certain ID, such as where ID = 12345. I then would like to have separate outputs with the rows where the ID is found for each table.&amp;amp;nbsp; The tables are very different in structure so cannot be stacked.&amp;amp;nbsp; The ID field is named the same in each table.&lt;BR /&gt;&lt;BR /&gt;For example&lt;BR /&gt;&lt;BR /&gt;Need it so when ID12345 is found in tables A,C,D then I get separate outputs for A,C,D with all the rows that ID12345 is in. Next person I lookup could be in tables B,E,F, so I would need separate outputs for B,E,F where that person is found. The number of tables grow each year so I do not want to maintain a list of the tables, just know that they all have the same naming convention. I need all the fields in the dataset to output and not just ID.&lt;BR /&gt;&lt;BR /&gt;(Version 8.2)&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Thanks!</description>
      <pubDate>Fri, 23 Apr 2021 22:15:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-do-I-search-multiple-tables-output-when-find-condition/m-p/736666#M38681</guid>
      <dc:creator>cad88</dc:creator>
      <dc:date>2021-04-23T22:15:42Z</dc:date>
    </item>
    <item>
      <title>Re: How do I search multiple tables output when find condition</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-do-I-search-multiple-tables-output-when-find-condition/m-p/736672#M38683</link>
      <description>&lt;P&gt;If you're only filtering on ID why does it matter? Does this get you close?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
set lib.o_: indsname = source;
where id = 12345;
record = _n_;
file = source;

Keep ID;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 23 Apr 2021 21:24:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-do-I-search-multiple-tables-output-when-find-condition/m-p/736672#M38683</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2021-04-23T21:24:00Z</dc:date>
    </item>
    <item>
      <title>Re: How do I search multiple tables output when find condition</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-do-I-search-multiple-tables-output-when-find-condition/m-p/736673#M38684</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data o_girls   o_boys;
  set sashelp.class;
  if sex='F' then output o_girls;
  else output o_boys;
run;

data recombined;
  set o_: ;
  where name='John';
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 23 Apr 2021 21:25:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-do-I-search-multiple-tables-output-when-find-condition/m-p/736673#M38684</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2021-04-23T21:25:02Z</dc:date>
    </item>
    <item>
      <title>Re: How do I search multiple tables output when find condition</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-do-I-search-multiple-tables-output-when-find-condition/m-p/736680#M38685</link>
      <description>&lt;P&gt;Need it so when ID12345 is found in tables A,C,D then I get separate outputs for A,C,D with all the rows that ID12345 is in.&amp;nbsp; Next person I lookup could be in tables B,E,F, so I would need separate outputs for B,E,F&amp;nbsp; where that person is found.&amp;nbsp; The number of tables grow each year so I do not want to maintain a list of the tables, just know that they all have the same naming convention.&lt;/P&gt;</description>
      <pubDate>Fri, 23 Apr 2021 21:39:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-do-I-search-multiple-tables-output-when-find-condition/m-p/736680#M38685</guid>
      <dc:creator>cad88</dc:creator>
      <dc:date>2021-04-23T21:39:25Z</dc:date>
    </item>
    <item>
      <title>Re: How do I search multiple tables output when find condition</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-do-I-search-multiple-tables-output-when-find-condition/m-p/736685#M38686</link>
      <description>&lt;P&gt;Look in this thread: &lt;A href="https://communities.sas.com/t5/SAS-Programming/How-to-set-all-datasets-from-library/m-p/734182" target="_blank"&gt;https://communities.sas.com/t5/SAS-Programming/How-to-set-all-datasets-from-library/m-p/734182&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Has an example like yours that looks for "visit" instead of "ID".&lt;/P&gt;
&lt;P&gt;The example first builds a data set of nothing but the "visit" values and the dataset identification.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Caveats: This will only work if your variable is of the same type in all data sets.&lt;/P&gt;
&lt;P&gt;Second, if other common named variables in different datasets are of different types you will need to modify the code keep just the ID variable from each data set using something like&lt;/P&gt;
&lt;PRE&gt;  call execute(NAME || "(keep = id)" );&lt;/PRE&gt;
&lt;P&gt;Call execute places code in a buffer to execute after the end of the data step using it.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 23 Apr 2021 22:07:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-do-I-search-multiple-tables-output-when-find-condition/m-p/736685#M38686</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2021-04-23T22:07:00Z</dc:date>
    </item>
    <item>
      <title>Re: How do I search multiple tables output when find condition</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-do-I-search-multiple-tables-output-when-find-condition/m-p/737235#M38703</link>
      <description>Looking to have a separate output for each table with all the rows and fields.</description>
      <pubDate>Tue, 27 Apr 2021 12:25:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-do-I-search-multiple-tables-output-when-find-condition/m-p/737235#M38703</guid>
      <dc:creator>cad88</dc:creator>
      <dc:date>2021-04-27T12:25:02Z</dc:date>
    </item>
    <item>
      <title>Re: How do I search multiple tables output when find condition</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-do-I-search-multiple-tables-output-when-find-condition/m-p/737583#M38738</link>
      <description>&lt;P&gt;Something similar to this code may work:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc sql noprint;&lt;BR /&gt;select count(distinct memname) into :cnt from dictionary.columns&lt;BR /&gt;where libname = "WORK" and substr(upcase(memname),1,2) = "_O";&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;select distinct catx(".",libname,memname), catx(".",libname,trim(memname)||'_out')&lt;BR /&gt;into :dsnames1 - :dsnames%trim(%left(&amp;amp;cnt)),:dsout1 - :dsout%trim(%left(&amp;amp;cnt)) &lt;BR /&gt;from dictionary.columns&lt;BR /&gt;where libname = "WORK" and substr(upcase(memname),1,2) = "_O";&lt;BR /&gt;quit;&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;%macro split;&lt;BR /&gt;%do i=1 %to &amp;amp;cnt;&lt;BR /&gt;data &amp;amp;&amp;amp;dsout&amp;amp;i;&lt;BR /&gt;set &amp;amp;&amp;amp;dsnames&amp;amp;i;&lt;BR /&gt;where ID=12345;&lt;BR /&gt;run;&lt;BR /&gt;%end;&lt;/P&gt;
&lt;P&gt;%mend;&lt;/P&gt;
&lt;P&gt;%split;&lt;/P&gt;</description>
      <pubDate>Wed, 28 Apr 2021 14:17:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-do-I-search-multiple-tables-output-when-find-condition/m-p/737583#M38738</guid>
      <dc:creator>jebjur</dc:creator>
      <dc:date>2021-04-28T14:17:58Z</dc:date>
    </item>
    <item>
      <title>Re: How do I search multiple tables output when find condition</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-do-I-search-multiple-tables-output-when-find-condition/m-p/737591#M38739</link>
      <description>&lt;P&gt;So you want to do something like:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data work.o_a;
  set mylib.o_a;
  where ID = 12345;
run;

data work.o_b;
  set mylib.o_b;
  where ID = 12345;
run;

...&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;If so then all you need to do is get the list of dataset names.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql noprint;
  create table dslist as 
  select memname 
  from dictionary.columns
  where libname = 'MYLIB'
    and memname like 'O^_%' escape '^' 
    and upcase(name) = 'ID'
  ;
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;and use that to generate the code&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;filename code temp;
data _null_;
  set dslist ;
  file code ;
  put 
     'data work.' memname ';'
   / '  set mylib.' memname ';'
   / '  where ID = 12345;'
   / 'run;'
  ;
run;
%include code /source2;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 28 Apr 2021 14:37:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-do-I-search-multiple-tables-output-when-find-condition/m-p/737591#M38739</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2021-04-28T14:37:43Z</dc:date>
    </item>
    <item>
      <title>Re: How do I search multiple tables output when find condition</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-do-I-search-multiple-tables-output-when-find-condition/m-p/739494#M38777</link>
      <description>Great! Thank You! It did output an out table for all tables even if member was not in them but that was an easy fix.</description>
      <pubDate>Thu, 06 May 2021 14:21:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-do-I-search-multiple-tables-output-when-find-condition/m-p/739494#M38777</guid>
      <dc:creator>cad88</dc:creator>
      <dc:date>2021-05-06T14:21:10Z</dc:date>
    </item>
  </channel>
</rss>

