<?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: Finding the Number of Rows and Columns for each dataset in a library in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Finding-the-Number-of-Rows-and-Columns-for-each-dataset-in-a/m-p/378185#M276789</link>
    <description>&lt;P&gt;Oh yes, NVAR, good spot:&lt;/P&gt;
&lt;P&gt;Updated:&lt;/P&gt;
&lt;PRE&gt;data want_obs (keep=memname nobs nvar);
  set sashelp.vtable (where=(libname="&amp;lt;YOURLIB&amp;gt;"));
run;&lt;/PRE&gt;</description>
    <pubDate>Fri, 21 Jul 2017 15:07:19 GMT</pubDate>
    <dc:creator>RW9</dc:creator>
    <dc:date>2017-07-21T15:07:19Z</dc:date>
    <item>
      <title>Finding the Number of Rows and Columns for each dataset in a library</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Finding-the-Number-of-Rows-and-Columns-for-each-dataset-in-a/m-p/378175#M276784</link>
      <description>&lt;P&gt;Hey guys,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm relatively new to SAS and am trying to write a piece of code in SAS enterprise that finds the number of rows and columns for each data set in a library of 20 or so datasets. I know I need some sort of macro and possibly a nobs= statement but overall I'm generally lost. Any tips or suggestions to point me in the right direction would be much appreciated.&lt;/P&gt;</description>
      <pubDate>Fri, 21 Jul 2017 14:58:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Finding-the-Number-of-Rows-and-Columns-for-each-dataset-in-a/m-p/378175#M276784</guid>
      <dc:creator>larkjr18</dc:creator>
      <dc:date>2017-07-21T14:58:55Z</dc:date>
    </item>
    <item>
      <title>Re: Finding the Number of Rows and Columns for each dataset in a library</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Finding-the-Number-of-Rows-and-Columns-for-each-dataset-in-a/m-p/378178#M276785</link>
      <description>&lt;P&gt;And where do you get the idea you need macro?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;data want_obs (keep=memname nobs);
  set sashelp.vtables (where=(libname="&amp;lt;YOURLIB&amp;gt;"));
run;&lt;/PRE&gt;
&lt;P&gt;This will create a dataset with all the obs for each of the datasets in the given library - note replace that text with your libname in upper case.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Same for variables:&lt;/P&gt;
&lt;PRE&gt;data want_cols (keep=memname cnt);
  set sashelp.vcolumn (where=(libname="&amp;lt;YOUR_LIB"));
  by memname;
  retain cnt;
  if first.memname then cnt=1;
  else cnt=cnt+1;
  if last.memname then output;
run;&lt;/PRE&gt;
&lt;P&gt;This keeps a running count of columns per dataset and only outputs 1 row with count for each dataset.&lt;/P&gt;</description>
      <pubDate>Fri, 21 Jul 2017 15:02:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Finding-the-Number-of-Rows-and-Columns-for-each-dataset-in-a/m-p/378178#M276785</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2017-07-21T15:02:29Z</dc:date>
    </item>
    <item>
      <title>Re: Finding the Number of Rows and Columns for each dataset in a library</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Finding-the-Number-of-Rows-and-Columns-for-each-dataset-in-a/m-p/378179#M276786</link>
      <description>&lt;P&gt;You don't need a macro.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can simply look in data set (well, actually it's a data view) sashelp.vtable&lt;/P&gt;</description>
      <pubDate>Fri, 21 Jul 2017 15:03:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Finding-the-Number-of-Rows-and-Columns-for-each-dataset-in-a/m-p/378179#M276786</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2017-07-21T15:03:57Z</dc:date>
    </item>
    <item>
      <title>Re: Finding the Number of Rows and Columns for each dataset in a library</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Finding-the-Number-of-Rows-and-Columns-for-each-dataset-in-a/m-p/378183#M276787</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/45151"&gt;@RW9&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;And where do you get the idea you need macro?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;data want_obs (keep=memname nobs);
  set sashelp.vtables (where=(libname="&amp;lt;YOURLIB&amp;gt;"));
run;&lt;/PRE&gt;
&lt;P&gt;This will create a dataset with all the obs for each of the datasets in the given library - note replace that text with your libname in upper case.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Same for variables:&lt;/P&gt;
&lt;PRE&gt;data want_cols (keep=memname cnt);
  set sashelp.vcolumn (where=(libname="&amp;lt;YOUR_LIB"));
  by memname;
  retain cnt;
  if first.memname then cnt=1;
  else cnt=cnt+1;
  if last.memname then output;
run;&lt;/PRE&gt;
&lt;P&gt;This keeps a running count of columns per dataset and only outputs 1 row with count for each dataset.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;While this will work (except that it's sashelp.vtable and not vtables), the number of variables is in sashelp.vtable as well, no need to add up things in sashelp.vcolumn.&lt;/P&gt;</description>
      <pubDate>Fri, 21 Jul 2017 15:05:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Finding-the-Number-of-Rows-and-Columns-for-each-dataset-in-a/m-p/378183#M276787</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2017-07-21T15:05:52Z</dc:date>
    </item>
    <item>
      <title>Re: Finding the Number of Rows and Columns for each dataset in a library</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Finding-the-Number-of-Rows-and-Columns-for-each-dataset-in-a/m-p/378184#M276788</link>
      <description>&lt;P&gt;Have a look at sashelp.vtable:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
   select MemName, NVar, nobs
      from sashelp.vtable
         where Libname = 'YOUR_LIB'
   ;
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;To late &lt;span class="lia-unicode-emoji" title=":winking_face:"&gt;😉&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 21 Jul 2017 15:07:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Finding-the-Number-of-Rows-and-Columns-for-each-dataset-in-a/m-p/378184#M276788</guid>
      <dc:creator>andreas_lds</dc:creator>
      <dc:date>2017-07-21T15:07:27Z</dc:date>
    </item>
    <item>
      <title>Re: Finding the Number of Rows and Columns for each dataset in a library</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Finding-the-Number-of-Rows-and-Columns-for-each-dataset-in-a/m-p/378185#M276789</link>
      <description>&lt;P&gt;Oh yes, NVAR, good spot:&lt;/P&gt;
&lt;P&gt;Updated:&lt;/P&gt;
&lt;PRE&gt;data want_obs (keep=memname nobs nvar);
  set sashelp.vtable (where=(libname="&amp;lt;YOURLIB&amp;gt;"));
run;&lt;/PRE&gt;</description>
      <pubDate>Fri, 21 Jul 2017 15:07:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Finding-the-Number-of-Rows-and-Columns-for-each-dataset-in-a/m-p/378185#M276789</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2017-07-21T15:07:19Z</dc:date>
    </item>
    <item>
      <title>Re: Finding the Number of Rows and Columns for each dataset in a library</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Finding-the-Number-of-Rows-and-Columns-for-each-dataset-in-a/m-p/378200#M276790</link>
      <description>&lt;P&gt;All the info you need is sashelp.vtable and you can get by below query. Two things to keep in mind . SASHELP.vtable is dictionary view. Any queries run against dictionary views will be slow or very slow. So always have where clause and also put the libname you want&amp;nbsp;in upper case as shown in the code.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql ;
select libname, memname, nobs as totalrows, nvar as totalcolumns from sashelp.vtable
where libname in ('LIB1','LIB2');
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 21 Jul 2017 15:30:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Finding-the-Number-of-Rows-and-Columns-for-each-dataset-in-a/m-p/378200#M276790</guid>
      <dc:creator>kiranv_</dc:creator>
      <dc:date>2017-07-21T15:30:20Z</dc:date>
    </item>
  </channel>
</rss>

