<?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: get only existing tables in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/get-only-existing-tables/m-p/710795#M218875</link>
    <description>&lt;P&gt;Store such data in datasets instead of macro variables, and you can use a simple join:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data tables;
input dname $32.;
datalines;
table1
table2
table3
table4
table5
;

proc sql;
create table exist as
  select dname
  from tables t, dictionary.tables d
  where upcase(t.dname) = d.memname and d.libname = "WORK"
;
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 12 Jan 2021 12:29:39 GMT</pubDate>
    <dc:creator>Kurt_Bremser</dc:creator>
    <dc:date>2021-01-12T12:29:39Z</dc:date>
    <item>
      <title>get only existing tables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/get-only-existing-tables/m-p/710786#M218866</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;I&amp;nbsp;&amp;nbsp;have a macro varaible that contains the texte : table1 table2 table3 table4 table5 table6&lt;/P&gt;
&lt;P&gt;only table1 and table3 exists in the work librarie&lt;/P&gt;
&lt;P&gt;So i would like to get in a macro variable the text table1 table3&lt;/P&gt;
&lt;P&gt;thanks in advance for your help&lt;/P&gt;
&lt;P&gt;Nasser&lt;/P&gt;</description>
      <pubDate>Tue, 12 Jan 2021 11:57:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/get-only-existing-tables/m-p/710786#M218866</guid>
      <dc:creator>Nasser_DRMCP</dc:creator>
      <dc:date>2021-01-12T11:57:23Z</dc:date>
    </item>
    <item>
      <title>Re: get only existing tables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/get-only-existing-tables/m-p/710787#M218867</link>
      <description>&lt;P&gt;Are those the exact names involved or just generic?&lt;/P&gt;
&lt;P&gt;I ask because there are techniques that will work easier with an iterated name than with a list of explicit names.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You may need to show us how you are currently creating the macro variable.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;One approach looks like this:&lt;/P&gt;
&lt;PRE&gt;proc sql;
   select memname into: newlist separated by ' '
   from dictionary.tables
   where libname='WORK'
      and memname in ('TABLE1' 'TABLE2' 'TABLE3')
   ;
quit;&lt;/PRE&gt;
&lt;P&gt;But that would require a quoted list of values. Which likely means doing something with your current value.&lt;/P&gt;
&lt;P&gt;Which may require creating a helper macro to quote your existing value or make separately.&lt;/P&gt;</description>
      <pubDate>Tue, 12 Jan 2021 12:06:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/get-only-existing-tables/m-p/710787#M218867</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2021-01-12T12:06:13Z</dc:date>
    </item>
    <item>
      <title>Re: get only existing tables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/get-only-existing-tables/m-p/710789#M218869</link>
      <description>&lt;P&gt;This seems to be part of a bigger problem. What do you want to do with the new macro variable?&lt;/P&gt;</description>
      <pubDate>Tue, 12 Jan 2021 12:10:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/get-only-existing-tables/m-p/710789#M218869</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2021-01-12T12:10:23Z</dc:date>
    </item>
    <item>
      <title>Re: get only existing tables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/get-only-existing-tables/m-p/710795#M218875</link>
      <description>&lt;P&gt;Store such data in datasets instead of macro variables, and you can use a simple join:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data tables;
input dname $32.;
datalines;
table1
table2
table3
table4
table5
;

proc sql;
create table exist as
  select dname
  from tables t, dictionary.tables d
  where upcase(t.dname) = d.memname and d.libname = "WORK"
;
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 12 Jan 2021 12:29:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/get-only-existing-tables/m-p/710795#M218875</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2021-01-12T12:29:39Z</dc:date>
    </item>
    <item>
      <title>Re: get only existing tables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/get-only-existing-tables/m-p/710804#M218879</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If I interpret Nasser's question right, I think a blend of the first two answers works just fine:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data table1;name='table1';run;
data table2;name='table2';run;
data table3;name='table3';run;
data table4;name='table4';run;
data table5;name='table5';run;

proc sql;
  select memname into: newlist separated by ' '
  from dictionary.tables
  where memname in ('TABLE1' 'TABLE2' 'TABLE3') and libname = "WORK"
;quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 12 Jan 2021 14:15:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/get-only-existing-tables/m-p/710804#M218879</guid>
      <dc:creator>RexDeus9</dc:creator>
      <dc:date>2021-01-12T14:15:27Z</dc:date>
    </item>
  </channel>
</rss>

