<?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 Names of datasets in a library to write into a dataset in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Names-of-datasets-in-a-library-to-write-into-a-dataset/m-p/233405#M42610</link>
    <description>&lt;P&gt;Hello Everyone,&lt;BR /&gt;&amp;nbsp;&lt;BR /&gt;I do have a question regarding the folowing subject:&lt;BR /&gt;&amp;nbsp;&lt;BR /&gt;Assume you have the following datasets in your work library:&amp;nbsp; "customers" , "costs" , "revenues" and&amp;nbsp; "transactions". &lt;BR /&gt;&amp;nbsp;&lt;BR /&gt;How can I&amp;nbsp; efficiently&amp;nbsp;&amp;nbsp; write a macro which generates one dataset called "overview" with a variable named "datasetnames" in which the corresponding name of each of the dataset in my work library is written into.&lt;BR /&gt;&amp;nbsp;&lt;BR /&gt;So in the described case above the "overview" dataset should look like this:&lt;BR /&gt;&amp;nbsp;&lt;BR /&gt;&amp;nbsp;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;datasetnames&lt;BR /&gt;1&amp;nbsp;&amp;nbsp; &amp;nbsp;customers&lt;BR /&gt;2&amp;nbsp;&amp;nbsp; &amp;nbsp;costs&lt;BR /&gt;3&amp;nbsp;&amp;nbsp; &amp;nbsp;revenues&lt;BR /&gt;4&amp;nbsp;&amp;nbsp; &amp;nbsp;transactions&lt;BR /&gt;&amp;nbsp;&lt;BR /&gt;Thank you in advance for any help in this topic.&lt;/P&gt;</description>
    <pubDate>Fri, 06 Nov 2015 10:52:34 GMT</pubDate>
    <dc:creator>FK</dc:creator>
    <dc:date>2015-11-06T10:52:34Z</dc:date>
    <item>
      <title>Names of datasets in a library to write into a dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Names-of-datasets-in-a-library-to-write-into-a-dataset/m-p/233405#M42610</link>
      <description>&lt;P&gt;Hello Everyone,&lt;BR /&gt;&amp;nbsp;&lt;BR /&gt;I do have a question regarding the folowing subject:&lt;BR /&gt;&amp;nbsp;&lt;BR /&gt;Assume you have the following datasets in your work library:&amp;nbsp; "customers" , "costs" , "revenues" and&amp;nbsp; "transactions". &lt;BR /&gt;&amp;nbsp;&lt;BR /&gt;How can I&amp;nbsp; efficiently&amp;nbsp;&amp;nbsp; write a macro which generates one dataset called "overview" with a variable named "datasetnames" in which the corresponding name of each of the dataset in my work library is written into.&lt;BR /&gt;&amp;nbsp;&lt;BR /&gt;So in the described case above the "overview" dataset should look like this:&lt;BR /&gt;&amp;nbsp;&lt;BR /&gt;&amp;nbsp;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;datasetnames&lt;BR /&gt;1&amp;nbsp;&amp;nbsp; &amp;nbsp;customers&lt;BR /&gt;2&amp;nbsp;&amp;nbsp; &amp;nbsp;costs&lt;BR /&gt;3&amp;nbsp;&amp;nbsp; &amp;nbsp;revenues&lt;BR /&gt;4&amp;nbsp;&amp;nbsp; &amp;nbsp;transactions&lt;BR /&gt;&amp;nbsp;&lt;BR /&gt;Thank you in advance for any help in this topic.&lt;/P&gt;</description>
      <pubDate>Fri, 06 Nov 2015 10:52:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Names-of-datasets-in-a-library-to-write-into-a-dataset/m-p/233405#M42610</guid>
      <dc:creator>FK</dc:creator>
      <dc:date>2015-11-06T10:52:34Z</dc:date>
    </item>
    <item>
      <title>Re: Names of datasets in a library to write into a dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Names-of-datasets-in-a-library-to-write-into-a-dataset/m-p/233410#M42614</link>
      <description>&lt;P&gt;I think you dont have to write macro..try the below codes;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;Proc contents data = work._ALL_ nods out= abc;
run;&lt;/PRE&gt;</description>
      <pubDate>Fri, 06 Nov 2015 11:49:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Names-of-datasets-in-a-library-to-write-into-a-dataset/m-p/233410#M42614</guid>
      <dc:creator>pearsoninst</dc:creator>
      <dc:date>2015-11-06T11:49:05Z</dc:date>
    </item>
    <item>
      <title>Re: Names of datasets in a library to write into a dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Names-of-datasets-in-a-library-to-write-into-a-dataset/m-p/233411#M42615</link>
      <description>&lt;P&gt;For what purpose? &amp;nbsp;SAS has a set of metadata tables in SASHELP library which tell it what libraries, datasets, columns etc. are used. &amp;nbsp;Just query that:&lt;/P&gt;
&lt;P&gt;data want;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; set sashelp.vtable (where=(libname="WORK") keep=memname);&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;</description>
      <pubDate>Fri, 06 Nov 2015 11:50:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Names-of-datasets-in-a-library-to-write-into-a-dataset/m-p/233411#M42615</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2015-11-06T11:50:03Z</dc:date>
    </item>
    <item>
      <title>Re: Names of datasets in a library to write into a dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Names-of-datasets-in-a-library-to-write-into-a-dataset/m-p/233414#M42618</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;proc sql;&lt;BR /&gt;create table dataname as&lt;BR /&gt;select memname as datasetnames from dictionary.columns&lt;BR /&gt;where libname='WORK';&lt;BR /&gt;quit;&lt;/P&gt;</description>
      <pubDate>Fri, 06 Nov 2015 12:15:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Names-of-datasets-in-a-library-to-write-into-a-dataset/m-p/233414#M42618</guid>
      <dc:creator>slchen</dc:creator>
      <dc:date>2015-11-06T12:15:06Z</dc:date>
    </item>
    <item>
      <title>Re: Names of datasets in a library to write into a dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Names-of-datasets-in-a-library-to-write-into-a-dataset/m-p/233415#M42619</link>
      <description>&lt;P&gt;If you really want a macro to perform this task, you could try something like this:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro listds(lib=work, out=overview, namevar=datasetnames, order=memname);
  proc sql;
  create table &amp;amp;out as
  select memname as &amp;amp;namevar
  from dictionary.tables
  where libname="%upcase(&amp;amp;lib)" &amp;amp; memtype='DATA'
  order by &amp;amp;order;
  quit;
%mend listds;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Here you have the flexibility of specifying&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;the library you're interested in (parameter &lt;FONT face="courier new,courier"&gt;lib&lt;/FONT&gt;, default: &lt;FONT face="courier new,courier"&gt;work&lt;/FONT&gt;)&lt;/LI&gt;
&lt;LI&gt;the name of the output dataset (&lt;SPAN&gt;parameter &lt;FONT face="courier new,courier"&gt;out&lt;/FONT&gt;,&amp;nbsp;default: &lt;FONT face="courier new,courier"&gt;overview&lt;/FONT&gt;)&lt;/SPAN&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;SPAN&gt;the name of the variable containing the dataset names (&lt;SPAN&gt;parameter &lt;FONT face="courier new,courier"&gt;namevar&lt;/FONT&gt;,&amp;nbsp;default: &lt;FONT face="courier new,courier"&gt;datasetnames&lt;/FONT&gt;)&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;SPAN&gt;&lt;SPAN&gt;the characteristic by which the dataset names are ordered (parameter &lt;FONT face="courier new,courier"&gt;order&lt;/FONT&gt;&lt;SPAN&gt;,&amp;nbsp;default: &lt;/SPAN&gt;&lt;FONT face="courier new,courier"&gt;memname&lt;FONT face="arial,helvetica,sans-serif"&gt;&amp;nbsp;[i.e. the dataset name]; other options include&lt;/FONT&gt; crdate&lt;FONT face="arial,helvetica,sans-serif"&gt;&amp;nbsp;[i.e. creation date],&lt;/FONT&gt; modate&lt;FONT face="arial,helvetica,sans-serif"&gt;&amp;nbsp;[i.e. last modification date], or&lt;/FONT&gt; filesize&lt;/FONT&gt;&lt;SPAN&gt;).&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;Sample calls:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%listds; &amp;nbsp;/* gives what you have described, however sorted alphabetically by dataset name */
%listds(lib=mylib, out=newlib.dslist, namevar=dsname, order=crdate) /*&amp;nbsp;assuming that libraries mylib and newlib exist */&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;For more options regarding parameter &lt;FONT face="courier new,courier"&gt;order&lt;/FONT&gt; see the description of &lt;FONT face="courier new,courier"&gt;dictionary.tables&lt;/FONT&gt;:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
describe table dictionary.tables;
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 06 Nov 2015 12:25:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Names-of-datasets-in-a-library-to-write-into-a-dataset/m-p/233415#M42619</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2015-11-06T12:25:41Z</dc:date>
    </item>
    <item>
      <title>Re: Names of datasets in a library to write into a dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Names-of-datasets-in-a-library-to-write-into-a-dataset/m-p/234815#M42972</link>
      <description>&lt;P&gt;Thank's guys for helping me out!&lt;/P&gt;</description>
      <pubDate>Sun, 15 Nov 2015 18:15:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Names-of-datasets-in-a-library-to-write-into-a-dataset/m-p/234815#M42972</guid>
      <dc:creator>FK</dc:creator>
      <dc:date>2015-11-15T18:15:57Z</dc:date>
    </item>
  </channel>
</rss>

