<?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: variables and obs count for each dataset in a library in Statistical Procedures</title>
    <link>https://communities.sas.com/t5/Statistical-Procedures/variables-and-obs-count-for-each-dataset-in-a-library/m-p/732811#M35560</link>
    <description>&lt;P&gt;You can get this information from the SAS dictionary table &lt;EM&gt;dictionary.tables&lt;/EM&gt;. Below an examples for library WORK.&lt;/P&gt;
&lt;P&gt;IF there could be any ds in-place delete (i.e. using Proc SQL or data step modify statement) then note that rows don't get deleted physically but only logically. The logically deleted rows get only removed if the table gets physically re-created.&lt;/P&gt;
&lt;P&gt;In below example investigate the values in &lt;EM&gt;nobs&lt;/EM&gt;, &lt;EM&gt;delobs&lt;/EM&gt; and &lt;EM&gt;nlobs&lt;/EM&gt;.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data work.class;
  set sashelp.class;
run;

proc sql;
  delete from work.class
  where name='Alfred'
  ;
quit;

proc sql;
  select 
    libname,
    memname,
    nvar,
    nobs,
    delobs,
    nlobs
  from dictionary.tables
  where 
    libname='WORK' 
/*    and memname='CLASS'*/
  ;
quit;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Also: You will get obs counts from libraries pointing to SAS files. Libraries pointing to databases will show missings for nobs/delobs/nlobs.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Databases don't maintain the number of rows in a table as metadata but you need to issue a &lt;EM&gt;select count(*)&lt;/EM&gt;&amp;nbsp;against the table to retrieve such information.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Below code will write to the SAS log what columns/information are available in &lt;EM&gt;dictionary.tables&lt;/EM&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;</description>
    <pubDate>Sun, 11 Apr 2021 02:06:51 GMT</pubDate>
    <dc:creator>Patrick</dc:creator>
    <dc:date>2021-04-11T02:06:51Z</dc:date>
    <item>
      <title>variables and obs count for each dataset in a library</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/variables-and-obs-count-for-each-dataset-in-a-library/m-p/732693#M35557</link>
      <description>&lt;P&gt;How to find variables and observation count for each dataset in a Library&lt;/P&gt;</description>
      <pubDate>Sat, 10 Apr 2021 10:44:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/variables-and-obs-count-for-each-dataset-in-a-library/m-p/732693#M35557</guid>
      <dc:creator>BrahmanandaRao</dc:creator>
      <dc:date>2021-04-10T10:44:09Z</dc:date>
    </item>
    <item>
      <title>Re: variables and obs count for each dataset in a library</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/variables-and-obs-count-for-each-dataset-in-a-library/m-p/732695#M35558</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Use the dictionary tables and go on from there.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Do something like:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;PROC SQL noprint;
 create table abc as
 select *
 from dictionary.columns
 where LIBNAME='MYLIB';
QUIT;
PROC SQL noprint;
 create table def as
 select *
 from dictionary.tables
 where LIBNAME='MYLIB';
QUIT;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Cheers,&lt;/P&gt;
&lt;P&gt;Koen&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 10 Apr 2021 11:00:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/variables-and-obs-count-for-each-dataset-in-a-library/m-p/732695#M35558</guid>
      <dc:creator>sbxkoenk</dc:creator>
      <dc:date>2021-04-10T11:00:42Z</dc:date>
    </item>
    <item>
      <title>Re: variables and obs count for each dataset in a library</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/variables-and-obs-count-for-each-dataset-in-a-library/m-p/732696#M35559</link>
      <description>&lt;P&gt;try this.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
  set sashelp.vtable;
  where libname='XXX' and typemem='DATA';/* specify your libname in XXX */
  keep memname nobs nvar;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 10 Apr 2021 11:08:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/variables-and-obs-count-for-each-dataset-in-a-library/m-p/732696#M35559</guid>
      <dc:creator>japelin</dc:creator>
      <dc:date>2021-04-10T11:08:03Z</dc:date>
    </item>
    <item>
      <title>Re: variables and obs count for each dataset in a library</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/variables-and-obs-count-for-each-dataset-in-a-library/m-p/732811#M35560</link>
      <description>&lt;P&gt;You can get this information from the SAS dictionary table &lt;EM&gt;dictionary.tables&lt;/EM&gt;. Below an examples for library WORK.&lt;/P&gt;
&lt;P&gt;IF there could be any ds in-place delete (i.e. using Proc SQL or data step modify statement) then note that rows don't get deleted physically but only logically. The logically deleted rows get only removed if the table gets physically re-created.&lt;/P&gt;
&lt;P&gt;In below example investigate the values in &lt;EM&gt;nobs&lt;/EM&gt;, &lt;EM&gt;delobs&lt;/EM&gt; and &lt;EM&gt;nlobs&lt;/EM&gt;.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data work.class;
  set sashelp.class;
run;

proc sql;
  delete from work.class
  where name='Alfred'
  ;
quit;

proc sql;
  select 
    libname,
    memname,
    nvar,
    nobs,
    delobs,
    nlobs
  from dictionary.tables
  where 
    libname='WORK' 
/*    and memname='CLASS'*/
  ;
quit;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Also: You will get obs counts from libraries pointing to SAS files. Libraries pointing to databases will show missings for nobs/delobs/nlobs.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Databases don't maintain the number of rows in a table as metadata but you need to issue a &lt;EM&gt;select count(*)&lt;/EM&gt;&amp;nbsp;against the table to retrieve such information.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Below code will write to the SAS log what columns/information are available in &lt;EM&gt;dictionary.tables&lt;/EM&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;</description>
      <pubDate>Sun, 11 Apr 2021 02:06:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/variables-and-obs-count-for-each-dataset-in-a-library/m-p/732811#M35560</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2021-04-11T02:06:51Z</dc:date>
    </item>
  </channel>
</rss>

