<?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 all table names from the database in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Read-all-table-names-from-the-database/m-p/499024#M72547</link>
    <description>&lt;P&gt;Instead of using the special ODBC views to query the database, you can also assign it as a SAS libname:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;libname dw odbc dsn='EDS' uid=dw pwd=dw schema=dbo;

&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;(I assume that you are using the default schema, DBO, as your ODBC table names have no prefix).&lt;/P&gt;&lt;P&gt;You can then open the library dw using the Explorer window, or you can use dictionary.tables and dictionary.columns in SQL to see the contents.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Or you can copy all the stuff to WORK in one fell swoop:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc copy in=dw out=Work mt=data;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Wed, 26 Sep 2018 11:28:12 GMT</pubDate>
    <dc:creator>s_lassen</dc:creator>
    <dc:date>2018-09-26T11:28:12Z</dc:date>
    <item>
      <title>Read all table names from the database</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Read-all-table-names-from-the-database/m-p/498843#M72531</link>
      <description>&lt;P&gt;Hi all,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want to read all the table names from the database (dsn 'EDS').Currently I knew only 2 tables names to view all the data content information.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;How can I pull all the table info from the database?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;&lt;STRONG&gt;proc&lt;/STRONG&gt;&lt;/FONT&gt; &lt;STRONG&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;sql&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;connect&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Courier New" size="2"&gt;to&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; odbc &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;as&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; DW (dsn=&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="2"&gt;"EDS"&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; uid=dw pwd=dw);&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;create&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Courier New" size="2"&gt;table&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; hospmst &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;as&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Courier New" size="2"&gt;select&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; * &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;from&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; connection to DW (&lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;select&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; * &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;from&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; HOSPMaster);&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;create&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Courier New" size="2"&gt;table&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; hospdiv &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;as&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Courier New" size="2"&gt;select&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; * &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;from&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; connection to DW (&lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;select&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; * &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;from&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; HOSPdivisions&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;);&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;&lt;STRONG&gt;quit&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="2"&gt;Thanks in Advance.&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="2"&gt;Thanks.&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 25 Sep 2018 19:50:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Read-all-table-names-from-the-database/m-p/498843#M72531</guid>
      <dc:creator>cho16</dc:creator>
      <dc:date>2018-09-25T19:50:40Z</dc:date>
    </item>
    <item>
      <title>Re: Read all table names from the database</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Read-all-table-names-from-the-database/m-p/498852#M72532</link>
      <description>&lt;P&gt;Most databases have some form of a dictionary table that lists all the tables and views. You may not have access to all the table and views but you should be able to query the table. Exactly how is dependent on your server, since you're using Pass-Through SQL. So you'll need to know what the underlying server is and the query that works in that particular language.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/73714"&gt;@cho16&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hi all,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I want to read all the table names from the database (dsn 'EDS').Currently I knew only 2 tables names to view all the data content information.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;How can I pull all the table info from the database?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="2" color="#000080"&gt;&lt;STRONG&gt;proc&lt;/STRONG&gt;&lt;/FONT&gt; &lt;STRONG&gt;&lt;FONT face="Courier New" size="2" color="#000080"&gt;sql&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="2" color="#0000ff"&gt;connect&lt;/FONT&gt; &lt;FONT face="Courier New" size="2" color="#0000ff"&gt;to&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; odbc &lt;/FONT&gt;&lt;FONT face="Courier New" size="2" color="#0000ff"&gt;as&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; DW (dsn=&lt;/FONT&gt;&lt;FONT face="Courier New" size="2" color="#800080"&gt;"EDS"&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; uid=dw pwd=dw);&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="2" color="#0000ff"&gt;create&lt;/FONT&gt; &lt;FONT face="Courier New" size="2" color="#0000ff"&gt;table&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; hospmst &lt;/FONT&gt;&lt;FONT face="Courier New" size="2" color="#0000ff"&gt;as&lt;/FONT&gt; &lt;FONT face="Courier New" size="2" color="#0000ff"&gt;select&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; * &lt;/FONT&gt;&lt;FONT face="Courier New" size="2" color="#0000ff"&gt;from&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; connection to DW (&lt;/FONT&gt;&lt;FONT face="Courier New" size="2" color="#0000ff"&gt;select&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; * &lt;/FONT&gt;&lt;FONT face="Courier New" size="2" color="#0000ff"&gt;from&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; HOSPMaster);&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="2" color="#0000ff"&gt;create&lt;/FONT&gt; &lt;FONT face="Courier New" size="2" color="#0000ff"&gt;table&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; hospdiv &lt;/FONT&gt;&lt;FONT face="Courier New" size="2" color="#0000ff"&gt;as&lt;/FONT&gt; &lt;FONT face="Courier New" size="2" color="#0000ff"&gt;select&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; * &lt;/FONT&gt;&lt;FONT face="Courier New" size="2" color="#0000ff"&gt;from&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; connection to DW (&lt;/FONT&gt;&lt;FONT face="Courier New" size="2" color="#0000ff"&gt;select&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; * &lt;/FONT&gt;&lt;FONT face="Courier New" size="2" color="#0000ff"&gt;from&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; HOSPdivisions&lt;FONT face="Courier New" size="2" color="#0000ff"&gt;);&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="2" color="#000080"&gt;&lt;STRONG&gt;quit&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="2"&gt;Thanks in Advance.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="2"&gt;Thanks.&lt;/FONT&gt;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 25 Sep 2018 20:09:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Read-all-table-names-from-the-database/m-p/498852#M72532</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-09-25T20:09:39Z</dc:date>
    </item>
    <item>
      <title>Re: Read all table names from the database</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Read-all-table-names-from-the-database/m-p/498857#M72533</link>
      <description>&lt;P&gt;Building on the response from&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13879"&gt;@Reeza&lt;/a&gt;, &lt;A href="https://blogs.sas.com/content/sasdummy/2012/05/18/using-proc-sql-to-get-the-schema-of-a-mysql-database/" target="_self"&gt;here's a technique that works for MySQL&lt;/A&gt; and a number of other databases.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Code excerpt:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/* must be run where SAS/ACCESS to MySQL available */
%let database=dbname; /* name of the MySQL database */
%let server = mysql.host.domain.com; /* your MySQL node */
 
proc sql;
  connect to mysql as source 
    (
    DATABASE=&amp;amp;database 
    SERVER=&amp;amp;server 
    PORT=3306 /* default port, change if needed */
    USER=your_user_id
    PASSWORD=secretPW
    );
  create table work.schematables as 
    select * from connection to source 
    (select * from 
      information_schema.tables 
    where table_schema="&amp;amp;database");
 
  create table work.schemacolumns as 
    select * from connection to source 
    (select * from 
      information_schema.columns 
    where table_schema="&amp;amp;database");
  disconnect from source;
 
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 25 Sep 2018 20:27:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Read-all-table-names-from-the-database/m-p/498857#M72533</guid>
      <dc:creator>ChrisHemedinger</dc:creator>
      <dc:date>2018-09-25T20:27:19Z</dc:date>
    </item>
    <item>
      <title>Re: Read all table names from the database</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Read-all-table-names-from-the-database/m-p/498859#M72534</link>
      <description>&lt;P&gt;This all assumes you've done the obvious and asked your IT area if they have a list of data sets documented somewhere. For a full BI implementation that usually exists somewhere in some form. That's usually also helpful because it will have some business concepts attached to it.&lt;/P&gt;</description>
      <pubDate>Tue, 25 Sep 2018 20:29:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Read-all-table-names-from-the-database/m-p/498859#M72534</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-09-25T20:29:38Z</dc:date>
    </item>
    <item>
      <title>Re: Read all table names from the database</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Read-all-table-names-from-the-database/m-p/498865#M72535</link>
      <description>&lt;P&gt;Since you are using ODBC there is a special way to query that information.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="http://support.sas.com/documentation/cdl/en/acreldb/65247/HTML/default/viewer.htm#p1f29m86u65hken1deqcybowtgma.htm" target="_blank"&gt;http://support.sas.com/documentation/cdl/en/acreldb/65247/HTML/default/viewer.htm#p1f29m86u65hken1deqcybowtgma.htm&lt;/A&gt;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;&lt;SPAN&gt;This example returns a list of the columns in the CUSTOMERS table.&lt;/SPAN&gt;&lt;/P&gt;
&lt;PRE class="codeFragment"&gt;proc sql;
   connect to odbc as mydb
      (datasrc="SQL Server" user=testuser password=testpass);
   select * from connection to mydb
      (ODBC::SQLColumns (, , "CUSTOMERS"));
quit;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;</description>
      <pubDate>Tue, 25 Sep 2018 21:19:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Read-all-table-names-from-the-database/m-p/498865#M72535</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2018-09-25T21:19:53Z</dc:date>
    </item>
    <item>
      <title>Re: Read all table names from the database</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Read-all-table-names-from-the-database/m-p/499024#M72547</link>
      <description>&lt;P&gt;Instead of using the special ODBC views to query the database, you can also assign it as a SAS libname:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;libname dw odbc dsn='EDS' uid=dw pwd=dw schema=dbo;

&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;(I assume that you are using the default schema, DBO, as your ODBC table names have no prefix).&lt;/P&gt;&lt;P&gt;You can then open the library dw using the Explorer window, or you can use dictionary.tables and dictionary.columns in SQL to see the contents.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Or you can copy all the stuff to WORK in one fell swoop:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc copy in=dw out=Work mt=data;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 26 Sep 2018 11:28:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Read-all-table-names-from-the-database/m-p/499024#M72547</guid>
      <dc:creator>s_lassen</dc:creator>
      <dc:date>2018-09-26T11:28:12Z</dc:date>
    </item>
  </channel>
</rss>

