<?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 get the db2 table names in sas in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/get-the-db2-table-names-in-sas/m-p/845598#M334308</link>
    <description>&lt;P&gt;I have 2 questions .&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;1)How to access the table names from Db2 schema using sas&amp;nbsp; ,if the libnamestatement is as below?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;rsubmit;&lt;BR /&gt;libname ABC db2 complete="userid=XXXXX;pwd=XXX;datasource=XXXX;" &lt;BR /&gt;schema=ABC;&lt;BR /&gt;endrsubmit;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;2)Also if I want the table names having a particular column,&lt;/P&gt;
&lt;P&gt;Some how the below sql dictionary query does not give the required results .&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;rsubmit;&lt;BR /&gt;proc sql;&lt;BR /&gt;create table a as&lt;BR /&gt;select name &lt;BR /&gt;from dictionary.columns&lt;BR /&gt;where upcase(libname) = 'ABC' and upcase(memname) like '%TRANSFORM%';&lt;BR /&gt;quit;&lt;BR /&gt;endrsubmit;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Is the query wrong?&lt;/P&gt;</description>
    <pubDate>Tue, 22 Nov 2022 03:52:39 GMT</pubDate>
    <dc:creator>sfffdg</dc:creator>
    <dc:date>2022-11-22T03:52:39Z</dc:date>
    <item>
      <title>get the db2 table names in sas</title>
      <link>https://communities.sas.com/t5/SAS-Programming/get-the-db2-table-names-in-sas/m-p/845598#M334308</link>
      <description>&lt;P&gt;I have 2 questions .&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;1)How to access the table names from Db2 schema using sas&amp;nbsp; ,if the libnamestatement is as below?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;rsubmit;&lt;BR /&gt;libname ABC db2 complete="userid=XXXXX;pwd=XXX;datasource=XXXX;" &lt;BR /&gt;schema=ABC;&lt;BR /&gt;endrsubmit;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;2)Also if I want the table names having a particular column,&lt;/P&gt;
&lt;P&gt;Some how the below sql dictionary query does not give the required results .&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;rsubmit;&lt;BR /&gt;proc sql;&lt;BR /&gt;create table a as&lt;BR /&gt;select name &lt;BR /&gt;from dictionary.columns&lt;BR /&gt;where upcase(libname) = 'ABC' and upcase(memname) like '%TRANSFORM%';&lt;BR /&gt;quit;&lt;BR /&gt;endrsubmit;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Is the query wrong?&lt;/P&gt;</description>
      <pubDate>Tue, 22 Nov 2022 03:52:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/get-the-db2-table-names-in-sas/m-p/845598#M334308</guid>
      <dc:creator>sfffdg</dc:creator>
      <dc:date>2022-11-22T03:52:39Z</dc:date>
    </item>
    <item>
      <title>Re: get the db2 table names in sas</title>
      <link>https://communities.sas.com/t5/SAS-Programming/get-the-db2-table-names-in-sas/m-p/845607#M334311</link>
      <description>Your code look right. Make sure Libname is successfully assigned. (Especially the SCHEMA is right)&lt;BR /&gt;Or could try this :&lt;BR /&gt;&lt;BR /&gt;libname ABC db2 dsn=xxx schema=ABC;&lt;BR /&gt;&lt;BR /&gt;proc sql;&lt;BR /&gt;connect to db2(dsn=xxx user=xxx pw=xxx);&lt;BR /&gt;select * from &lt;BR /&gt; connection to db2(DB2::SQLTables);&lt;BR /&gt;quit;</description>
      <pubDate>Tue, 22 Nov 2022 04:54:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/get-the-db2-table-names-in-sas/m-p/845607#M334311</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2022-11-22T04:54:27Z</dc:date>
    </item>
    <item>
      <title>Re: get the db2 table names in sas</title>
      <link>https://communities.sas.com/t5/SAS-Programming/get-the-db2-table-names-in-sas/m-p/845613#M334315</link>
      <description>&lt;P&gt;Your SQL looks right BUT it needs to be in the place where you issue the libname statement.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You have two rsubmit blocks - one where you execute the libname and one where you execute the SQL.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;rsubmit creates a new SAS session and the libname statement will only be valid within this SAS session. If you don't "config" your 2nd rsubmit in a way that it re-connects to the session you created with the first rsubmit then the libref won't exist and though the SQL querying the dictionary tables with a selection on this libref will return zero rows.&lt;/P&gt;
&lt;P&gt;The SQL as such looks o.k.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Do you need rsubmit blocks at all? The only reason would be that you need to connect to a different SAS server which has the access to the database ...but then the rsubmit would highly likely have some more options.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 22 Nov 2022 06:04:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/get-the-db2-table-names-in-sas/m-p/845613#M334315</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2022-11-22T06:04:35Z</dc:date>
    </item>
    <item>
      <title>Re: get the db2 table names in sas</title>
      <link>https://communities.sas.com/t5/SAS-Programming/get-the-db2-table-names-in-sas/m-p/845629#M334324</link>
      <description>&lt;P&gt;Maxim 2: Read the Log.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;See if the LIBNAME works at all.&lt;/P&gt;
&lt;P&gt;If in doubt, run both code parts in a single RSUBMIT and post the log here, using this button:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Bildschirmfoto 2020-04-07 um 08.32.59.jpg" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/54552i914D97BE1B0F21E5/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Bildschirmfoto 2020-04-07 um 08.32.59.jpg" alt="Bildschirmfoto 2020-04-07 um 08.32.59.jpg" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 22 Nov 2022 08:34:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/get-the-db2-table-names-in-sas/m-p/845629#M334324</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2022-11-22T08:34:04Z</dc:date>
    </item>
    <item>
      <title>Re: get the db2 table names in sas</title>
      <link>https://communities.sas.com/t5/SAS-Programming/get-the-db2-table-names-in-sas/m-p/845638#M334328</link>
      <description />
      <pubDate>Tue, 22 Nov 2022 10:46:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/get-the-db2-table-names-in-sas/m-p/845638#M334328</guid>
      <dc:creator>sfffdg</dc:creator>
      <dc:date>2022-11-22T10:46:03Z</dc:date>
    </item>
    <item>
      <title>Re: get the db2 table names in sas</title>
      <link>https://communities.sas.com/t5/SAS-Programming/get-the-db2-table-names-in-sas/m-p/845639#M334329</link>
      <description>&lt;P&gt;Do you get any result if just selecting for the libname on its own?&lt;BR /&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;where libname = 'LIB1'&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I've run below code using a libname that points to Postgres and things work as expected. I'm not aware that there is anything "special" with DB2 that would prevent such code to work.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
  create table test as
  select memname, name
  from dictionary.columns
  where 
    upcase(libname) = 'ABC'  
    and upcase(name) like 'ENTRY%'
  order by memname,name
  ;
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 22 Nov 2022 11:00:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/get-the-db2-table-names-in-sas/m-p/845639#M334329</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2022-11-22T11:00:28Z</dc:date>
    </item>
    <item>
      <title>Re: get the db2 table names in sas</title>
      <link>https://communities.sas.com/t5/SAS-Programming/get-the-db2-table-names-in-sas/m-p/845707#M334340</link>
      <description>&lt;P&gt;Two reasons why this might not give you desired result:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;- You don't have the appropriate authorization for the tables you wish to query.&lt;/P&gt;
&lt;P&gt;- Some table (and column) names may exceed SAS 32 char limit for object names. They will be visible using&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/18408"&gt;@Ksharp&lt;/a&gt;s method though.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 22 Nov 2022 16:35:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/get-the-db2-table-names-in-sas/m-p/845707#M334340</guid>
      <dc:creator>LinusH</dc:creator>
      <dc:date>2022-11-22T16:35:00Z</dc:date>
    </item>
  </channel>
</rss>

