<?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: How to get a list of all datasets and their variables in a sas library? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-get-a-list-of-all-datasets-and-their-variables-in-a-sas/m-p/889513#M351463</link>
    <description>&lt;P&gt;Check out sashelp.vcolumn and sashelp.vtable views in the sashelp library.&lt;/P&gt;</description>
    <pubDate>Wed, 16 Aug 2023 14:49:52 GMT</pubDate>
    <dc:creator>Reeza</dc:creator>
    <dc:date>2023-08-16T14:49:52Z</dc:date>
    <item>
      <title>How to get a list of all datasets and their variables in a sas library?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-get-a-list-of-all-datasets-and-their-variables-in-a-sas/m-p/889509#M351460</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a library of 100+ datasets each with 10+variables. I was wondering if it was possible to output an excel table that had the table name and the column names to the right kind of like the format below.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Dataset_name1 | variable_1 | variable_2&amp;nbsp;&lt;BR /&gt;dataset_name2 | variable_1 | variable_2| ....&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any help would be greatly appreciated.&lt;BR /&gt;&lt;BR /&gt;Thank you.&lt;/P&gt;</description>
      <pubDate>Wed, 16 Aug 2023 14:38:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-get-a-list-of-all-datasets-and-their-variables-in-a-sas/m-p/889509#M351460</guid>
      <dc:creator>aasdfafafsdfsaf</dc:creator>
      <dc:date>2023-08-16T14:38:27Z</dc:date>
    </item>
    <item>
      <title>Re: How to get a list of all datasets and their variables in a sas library?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-get-a-list-of-all-datasets-and-their-variables-in-a-sas/m-p/889513#M351463</link>
      <description>&lt;P&gt;Check out sashelp.vcolumn and sashelp.vtable views in the sashelp library.&lt;/P&gt;</description>
      <pubDate>Wed, 16 Aug 2023 14:49:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-get-a-list-of-all-datasets-and-their-variables-in-a-sas/m-p/889513#M351463</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2023-08-16T14:49:52Z</dc:date>
    </item>
    <item>
      <title>Re: How to get a list of all datasets and their variables in a sas library?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-get-a-list-of-all-datasets-and-their-variables-in-a-sas/m-p/889517#M351467</link>
      <description>&lt;P&gt;Something like this perhaps? You would specify your library name instead of WORK and the name stored is in uppercase so provide it that way.&lt;/P&gt;
&lt;PRE&gt;proc transpose data=sashelp.vcolumn 
   out= trans  (drop=_name_ _label_)
   prefix=Varname;
   where libname='WORK';
   by memname;
   var name;
run; 

proc print data=trans;
run;&lt;/PRE&gt;
&lt;P&gt;Depending on the &lt;STRONG&gt;purpose&lt;/STRONG&gt; of this exercise there are other ways to use the Vcolumn data.&lt;/P&gt;
&lt;P&gt;For example this creates a table that checks if the variables of the same name are of the same type&lt;/P&gt;
&lt;PRE&gt;proc tabulate data=sashelp.vcolumn;
   where libname='WORK';
   class memname name type;
   table name*type,
         memname*n=' '
         /misstext=' '
   ;
run;&lt;/PRE&gt;
&lt;P&gt;The columns are the data sets a 1 indicates that the variable name and type on the left of the row is in the data set.&lt;/P&gt;
&lt;P&gt;If you have two types for the same variable they would be next to each other in rows to see which is where.&lt;/P&gt;
&lt;P&gt;The n =' ' suppresses the column label of N. The Misstex=' ' table option displays no text instead of the default . for all the missing counts (variables not in the given data set column)&lt;/P&gt;</description>
      <pubDate>Wed, 16 Aug 2023 15:09:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-get-a-list-of-all-datasets-and-their-variables-in-a-sas/m-p/889517#M351467</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2023-08-16T15:09:27Z</dc:date>
    </item>
    <item>
      <title>Re: How to get a list of all datasets and their variables in a sas library?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-get-a-list-of-all-datasets-and-their-variables-in-a-sas/m-p/889528#M351475</link>
      <description>&lt;P&gt;That is what PROC CONTENTS is for.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc contents data=mylib._all_ noprint out=contents; run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;What do you want to DO with the list?&amp;nbsp; if you would like it to appear in that strange wide format then transpose the data.&lt;/P&gt;
&lt;PRE&gt;proc sort data=contents;
  by libname memname varnum ;
run;

proc transpose data=contents out=wide(drop=_name_ _label_) prefix=var;
  by libname memname ;
  id varnum;
  var name;
run;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Tom_0-1692203532793.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/86747i97556FD36714221F/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Tom_0-1692203532793.png" alt="Tom_0-1692203532793.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 16 Aug 2023 16:32:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-get-a-list-of-all-datasets-and-their-variables-in-a-sas/m-p/889528#M351475</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2023-08-16T16:32:20Z</dc:date>
    </item>
    <item>
      <title>Re: How to get a list of all datasets and their variables in a sas library?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-get-a-list-of-all-datasets-and-their-variables-in-a-sas/m-p/929519#M365742</link>
      <description>&lt;P&gt;That was helpful&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13879"&gt;@Reeza&lt;/a&gt;&amp;nbsp;!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;- Dr. Abhijeet Safai&lt;/P&gt;</description>
      <pubDate>Fri, 24 May 2024 05:11:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-get-a-list-of-all-datasets-and-their-variables-in-a-sas/m-p/929519#M365742</guid>
      <dc:creator>DrAbhijeetSafai</dc:creator>
      <dc:date>2024-05-24T05:11:00Z</dc:date>
    </item>
    <item>
      <title>Re: How to get a list of all datasets and their variables in a sas library?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-get-a-list-of-all-datasets-and-their-variables-in-a-sas/m-p/929574#M365762</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/27897"&gt;@DrAbhijeetSafai&lt;/a&gt;&amp;nbsp;Just adding the bit of code required to store the result in a Excel sheet. Else just using Tom's code so suggest you accept his proposal as solution.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;options dlcreatedir;
libname mylib "%sysfunc(pathname(work))\source";
data mylib.class;
  set sashelp.class;
run;
data mylib.air;
  set sashelp.air;
run;

proc contents data=mylib._all_ noprint out=contents; 
run;

proc sort data=contents;
  by libname memname varnum ;
run;

libname exl xlsx "%sysfunc(pathname(work))\myexcle.xlsx";
proc transpose data=contents out=exl.wide(drop=_name_ _label_) prefix=var;
  by libname memname ;
  id varnum;
  var name;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 24 May 2024 10:02:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-get-a-list-of-all-datasets-and-their-variables-in-a-sas/m-p/929574#M365762</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2024-05-24T10:02:41Z</dc:date>
    </item>
  </channel>
</rss>

