<?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: PROC CONTENTS for Database Tables ONLY in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/PROC-CONTENTS-for-Database-Tables-ONLY/m-p/54359#M11533</link>
    <description>Hi.&lt;BR /&gt;
How about use dictionary.tables which also contain the information you want.&lt;BR /&gt;
[pre]&lt;BR /&gt;
proc sql;&lt;BR /&gt;
 select *&lt;BR /&gt;
  from dictionary.tables;&lt;BR /&gt;
quit;&lt;BR /&gt;
[/pre]&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
Ksharp</description>
    <pubDate>Thu, 21 Apr 2011 06:11:18 GMT</pubDate>
    <dc:creator>Ksharp</dc:creator>
    <dc:date>2011-04-21T06:11:18Z</dc:date>
    <item>
      <title>PROC CONTENTS for Database Tables ONLY</title>
      <link>https://communities.sas.com/t5/SAS-Programming/PROC-CONTENTS-for-Database-Tables-ONLY/m-p/54358#M11532</link>
      <description>Hi,&lt;BR /&gt;
&lt;BR /&gt;
I wanted to do a PROC CONTENTS and get the output for just the tables in a database referenced by a LIBNAME.  When I run&lt;BR /&gt;
&lt;BR /&gt;
PROC CONTENTS DATA=mylib._ALL_;&lt;BR /&gt;
&lt;BR /&gt;
it show all the database views and queries as well (they are tagged as such in the "DBMS Member Type" column.).  CONTENTS lists their "SAS" Member Type as DATA, so the MEMTYPE= option doesn't cut it.&lt;BR /&gt;
&lt;BR /&gt;
Any other ideas of how to limit the output?&lt;BR /&gt;
&lt;BR /&gt;
Thanks,&lt;BR /&gt;
Doc Muhlbaier&lt;BR /&gt;
Duke</description>
      <pubDate>Wed, 20 Apr 2011 21:16:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/PROC-CONTENTS-for-Database-Tables-ONLY/m-p/54358#M11532</guid>
      <dc:creator>Doc_Duke</dc:creator>
      <dc:date>2011-04-20T21:16:18Z</dc:date>
    </item>
    <item>
      <title>Re: PROC CONTENTS for Database Tables ONLY</title>
      <link>https://communities.sas.com/t5/SAS-Programming/PROC-CONTENTS-for-Database-Tables-ONLY/m-p/54359#M11533</link>
      <description>Hi.&lt;BR /&gt;
How about use dictionary.tables which also contain the information you want.&lt;BR /&gt;
[pre]&lt;BR /&gt;
proc sql;&lt;BR /&gt;
 select *&lt;BR /&gt;
  from dictionary.tables;&lt;BR /&gt;
quit;&lt;BR /&gt;
[/pre]&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
Ksharp</description>
      <pubDate>Thu, 21 Apr 2011 06:11:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/PROC-CONTENTS-for-Database-Tables-ONLY/m-p/54359#M11533</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2011-04-21T06:11:18Z</dc:date>
    </item>
    <item>
      <title>Re: PROC CONTENTS for Database Tables ONLY</title>
      <link>https://communities.sas.com/t5/SAS-Programming/PROC-CONTENTS-for-Database-Tables-ONLY/m-p/54360#M11534</link>
      <description>Following Ksharp's tip, it appears this should work:&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
LIBNAME DAT 'my:\mylib';&lt;BR /&gt;
&lt;BR /&gt;
PROC SQL ;&lt;BR /&gt;
  SELECT DISTINCT 'PROC CONTENTS DATA =DAT.' || COMPRESS(MEMNAME,' ') || ';' &lt;BR /&gt;
    INTO :STR SEPARATED BY ' ' &lt;BR /&gt;
	FROM DICTIONARY.COLUMNS WHERE MEMTYPE='DATA'  ;&lt;BR /&gt;
QUIT;&lt;BR /&gt;
&lt;BR /&gt;
&amp;amp;STR;&lt;BR /&gt;
&lt;BR /&gt;
RUN;&lt;BR /&gt;
&lt;BR /&gt;
You may want to change the where clause as this:&lt;BR /&gt;
&lt;BR /&gt;
WHERE MEMTYPE='DATA'  AND MEMNAME LIKE 'mytbl%'&lt;BR /&gt;
&lt;BR /&gt;
to list all tables with name begining 'mytbl'.&lt;BR /&gt;
&lt;BR /&gt;
Hope this helps.</description>
      <pubDate>Thu, 21 Apr 2011 12:12:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/PROC-CONTENTS-for-Database-Tables-ONLY/m-p/54360#M11534</guid>
      <dc:creator>buckeye</dc:creator>
      <dc:date>2011-04-21T12:12:29Z</dc:date>
    </item>
    <item>
      <title>Re: PROC CONTENTS for Database Tables ONLY</title>
      <link>https://communities.sas.com/t5/SAS-Programming/PROC-CONTENTS-for-Database-Tables-ONLY/m-p/54361#M11535</link>
      <description>I figured it was in the DICTIONARY somewhere, though it took multiple tables to get it.  I ultimately made it into a macro.  I'm sure it could be further spiffed with error checking and such, but this will suit my purposes.&lt;BR /&gt;
&lt;BR /&gt;
Doc&lt;BR /&gt;
&lt;BR /&gt;
%MACRO DBMScontents(dbmslib,outtab=Contents);&lt;BR /&gt;
* Print the contents of a DBMSs tables only;&lt;BR /&gt;
&lt;BR /&gt;
* only keep column attributes that are informative via DBMS;&lt;BR /&gt;
PROC SQL;&lt;BR /&gt;
CREATE TABLE &amp;amp;outtab AS&lt;BR /&gt;
SELECT col.memname, &lt;BR /&gt;
	col.varnum,&lt;BR /&gt;
	col.name, &lt;BR /&gt;
	col.type, &lt;BR /&gt;
	col.length, &lt;BR /&gt;
	col.format&lt;BR /&gt;
FROM&lt;BR /&gt;
	dictionary.columns AS Col,&lt;BR /&gt;
	dictionary.tables AS table&lt;BR /&gt;
WHERE table.dbms_memtype='TABLE'&lt;BR /&gt;
  AND table.libname =UPCASE("&amp;amp;dbmslib")&lt;BR /&gt;
  AND table.libname=col.libname&lt;BR /&gt;
  AND table.memname=col.memname&lt;BR /&gt;
ORDER BY col.memname, col.name&lt;BR /&gt;
  ;&lt;BR /&gt;
QUIT;&lt;BR /&gt;
RUN;&lt;BR /&gt;
&lt;BR /&gt;
PROC PRINT DATA=&amp;amp;outtab NOOBS;&lt;BR /&gt;
TITLE "Contents of Tables in LIBNAME &amp;amp;dbmslib";&lt;BR /&gt;
  BY memname;&lt;BR /&gt;
  PAGEBY memname;&lt;BR /&gt;
  RUN;&lt;BR /&gt;
&lt;BR /&gt;
%MEND dbmscontents;</description>
      <pubDate>Thu, 21 Apr 2011 15:40:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/PROC-CONTENTS-for-Database-Tables-ONLY/m-p/54361#M11535</guid>
      <dc:creator>Doc_Duke</dc:creator>
      <dc:date>2011-04-21T15:40:20Z</dc:date>
    </item>
  </channel>
</rss>

