<?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: number of observations in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/number-of-observations/m-p/66538#M14443</link>
    <description>[pre]&lt;BR /&gt;
proc contents data=work._all_ out=sum(keep=memname nobs);&lt;BR /&gt;
run;&lt;BR /&gt;
data want(drop=total);&lt;BR /&gt;
 set sum end=last;&lt;BR /&gt;
 total+nobs;&lt;BR /&gt;
 output;&lt;BR /&gt;
 if last then do;&lt;BR /&gt;
               memname='Total';&lt;BR /&gt;
               nobs=total;&lt;BR /&gt;
               output;&lt;BR /&gt;
             end;&lt;BR /&gt;
run;&lt;BR /&gt;
[/pre]&lt;BR /&gt;
Ksharp</description>
    <pubDate>Wed, 18 May 2011 10:16:34 GMT</pubDate>
    <dc:creator>Ksharp</dc:creator>
    <dc:date>2011-05-18T10:16:34Z</dc:date>
    <item>
      <title>number of observations</title>
      <link>https://communities.sas.com/t5/SAS-Programming/number-of-observations/m-p/66533#M14438</link>
      <description>In a library if there are 10 datasets and I would like to get the total number of observations from all the 10. is there any way other than using the proc sql and giving the each dataset name?</description>
      <pubDate>Tue, 17 May 2011 17:14:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/number-of-observations/m-p/66533#M14438</guid>
      <dc:creator>SASPhile</dc:creator>
      <dc:date>2011-05-17T17:14:59Z</dc:date>
    </item>
    <item>
      <title>Re: number of observations</title>
      <link>https://communities.sas.com/t5/SAS-Programming/number-of-observations/m-p/66534#M14439</link>
      <description>Hello SASPhile, &lt;BR /&gt;
&lt;BR /&gt;
This is my solution:&lt;BR /&gt;
[pre]&lt;BR /&gt;
proc SQL noprint;&lt;BR /&gt;
  select COUNT(distinct memname) as N into :N &lt;BR /&gt;
  from SASHELP.VMEMBER where libname="WORK" and memtype="DATA";&lt;BR /&gt;
  %let N=%TRIM(&amp;amp;N);&lt;BR /&gt;
  select distinct memname as name into :N1-:N&amp;amp;N &lt;BR /&gt;
  from SASHELP.VMEMBER where libname="WORK" and memtype="DATA";&lt;BR /&gt;
quit;&lt;BR /&gt;
%macro a;&lt;BR /&gt;
  %local i obs;&lt;BR /&gt;
  %global nobs;&lt;BR /&gt;
  %do i=1 %to &amp;amp;N;&lt;BR /&gt;
     proc SQL noprint;&lt;BR /&gt;
       select COUNT(*) as obs into :obs from &amp;amp;&amp;amp;n&amp;amp;i&lt;BR /&gt;
     ;quit; &lt;BR /&gt;
     %if &amp;amp;i = 1 %then %let nobs=&amp;amp;obs;&lt;BR /&gt;
     %let nobs=%EVAL(&amp;amp;nobs+&amp;amp;obs);&lt;BR /&gt;
  %end;&lt;BR /&gt;
%mend;&lt;BR /&gt;
%a; &lt;BR /&gt;
%put nobs=&amp;amp;nobs;&lt;BR /&gt;
[/pre]&lt;BR /&gt;
Sincerely,&lt;BR /&gt;
SPR</description>
      <pubDate>Tue, 17 May 2011 17:41:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/number-of-observations/m-p/66534#M14439</guid>
      <dc:creator>SPR</dc:creator>
      <dc:date>2011-05-17T17:41:52Z</dc:date>
    </item>
    <item>
      <title>Re: number of observations</title>
      <link>https://communities.sas.com/t5/SAS-Programming/number-of-observations/m-p/66535#M14440</link>
      <description>SPR,&lt;BR /&gt;
 will this display the datasetname and count ?</description>
      <pubDate>Tue, 17 May 2011 17:56:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/number-of-observations/m-p/66535#M14440</guid>
      <dc:creator>SASPhile</dc:creator>
      <dc:date>2011-05-17T17:56:29Z</dc:date>
    </item>
    <item>
      <title>Re: number of observations</title>
      <link>https://communities.sas.com/t5/SAS-Programming/number-of-observations/m-p/66536#M14441</link>
      <description>Try something like this (replace the SASHELP libref with your libref of interest - make sure you type the libref in all caps):&lt;BR /&gt;
&lt;BR /&gt;
proc sql;&lt;BR /&gt;
title 'Total Observations for all datasets in the SASHELP library';&lt;BR /&gt;
   select sum(nlobs) 'Total Observations' format=comma16. as TotObs&lt;BR /&gt;
   from dictionary.tables&lt;BR /&gt;
   where libname ='SASHELP'&lt;BR /&gt;
      and MEMTYPE='DATA'&lt;BR /&gt;
   ;&lt;BR /&gt;
title 'Observations for each dataset in the SASHELP library';&lt;BR /&gt;
   select MEMNAME 'Dataset', sum(nlobs) 'Obs' format=comma16. as Obs&lt;BR /&gt;
   from dictionary.tables&lt;BR /&gt;
   where libname ='SASHELP'&lt;BR /&gt;
      and MEMTYPE='DATA'&lt;BR /&gt;
   group by MEMNAME&lt;BR /&gt;
   ;&lt;BR /&gt;
quit;</description>
      <pubDate>Tue, 17 May 2011 18:04:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/number-of-observations/m-p/66536#M14441</guid>
      <dc:creator>SASJedi</dc:creator>
      <dc:date>2011-05-17T18:04:50Z</dc:date>
    </item>
    <item>
      <title>Re: number of observations</title>
      <link>https://communities.sas.com/t5/SAS-Programming/number-of-observations/m-p/66537#M14442</link>
      <description>This displays name and count:&lt;BR /&gt;
[pre]&lt;BR /&gt;
%macro a;&lt;BR /&gt;
  %local i obs;&lt;BR /&gt;
  %do i=1 %to &amp;amp;N;&lt;BR /&gt;
     proc SQL noprint;&lt;BR /&gt;
       select COUNT(*) as obs into :obs from &amp;amp;&amp;amp;n&amp;amp;i&lt;BR /&gt;
     ;quit; &lt;BR /&gt;
     %put DATASET=&amp;amp;&amp;amp;n&amp;amp;i obs=%TRIM(&amp;amp;obs);&lt;BR /&gt;
  %end;&lt;BR /&gt;
%mend;&lt;BR /&gt;
options nonotes;&lt;BR /&gt;
%a&lt;BR /&gt;
oprions notes;&lt;BR /&gt;
[/pre]&lt;BR /&gt;
SPR</description>
      <pubDate>Tue, 17 May 2011 18:13:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/number-of-observations/m-p/66537#M14442</guid>
      <dc:creator>SPR</dc:creator>
      <dc:date>2011-05-17T18:13:21Z</dc:date>
    </item>
    <item>
      <title>Re: number of observations</title>
      <link>https://communities.sas.com/t5/SAS-Programming/number-of-observations/m-p/66538#M14443</link>
      <description>[pre]&lt;BR /&gt;
proc contents data=work._all_ out=sum(keep=memname nobs);&lt;BR /&gt;
run;&lt;BR /&gt;
data want(drop=total);&lt;BR /&gt;
 set sum end=last;&lt;BR /&gt;
 total+nobs;&lt;BR /&gt;
 output;&lt;BR /&gt;
 if last then do;&lt;BR /&gt;
               memname='Total';&lt;BR /&gt;
               nobs=total;&lt;BR /&gt;
               output;&lt;BR /&gt;
             end;&lt;BR /&gt;
run;&lt;BR /&gt;
[/pre]&lt;BR /&gt;
Ksharp</description>
      <pubDate>Wed, 18 May 2011 10:16:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/number-of-observations/m-p/66538#M14443</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2011-05-18T10:16:34Z</dc:date>
    </item>
  </channel>
</rss>

