<?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 How to automatically count #rows of multiple data set and store each data set count in table in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-automatically-count-rows-of-multiple-data-set-and-store/m-p/415951#M280175</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am new to SAS programming. I just try to find optimization code for one my exercise.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have 3 SAS data set in my library.&amp;nbsp; eg: data_1,data_2 and data_3.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;what i want do that i need count each data set rows and store in table.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;expected result:&lt;/P&gt;&lt;TABLE border="0" cellspacing="0"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;Table&lt;/TD&gt;&lt;TD&gt;#Rows&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Data_1&lt;/TD&gt;&lt;TD&gt;40&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Data_2&lt;/TD&gt;&lt;TD&gt;30&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Data_3&lt;/TD&gt;&lt;TD&gt;230&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;i can simply do like this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Proc sql;&lt;/P&gt;&lt;P&gt;create table ds.report&amp;nbsp; as&lt;/P&gt;&lt;P&gt;select '&lt;SPAN&gt;Data_1' as Table, count(*) from ds.Data_1&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;union&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;select 'Data_1' as Table, count(*) from ds.Data_2&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;union&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;select 'Data_1' as Table, count(*) from ds.Data_3;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;quit;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;this solution basic school level and okay for small count of file. but i looking for&amp;nbsp;simple code.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;eg: I can easily do this in qlikview.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Report:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Load&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Select tablename() as Table, count(*) from&amp;nbsp;Data_*;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Looking forward your advise for this case.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Best,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Robert&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 24 Nov 2017 08:59:54 GMT</pubDate>
    <dc:creator>robert_bos</dc:creator>
    <dc:date>2017-11-24T08:59:54Z</dc:date>
    <item>
      <title>How to automatically count #rows of multiple data set and store each data set count in table</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-automatically-count-rows-of-multiple-data-set-and-store/m-p/415951#M280175</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am new to SAS programming. I just try to find optimization code for one my exercise.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have 3 SAS data set in my library.&amp;nbsp; eg: data_1,data_2 and data_3.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;what i want do that i need count each data set rows and store in table.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;expected result:&lt;/P&gt;&lt;TABLE border="0" cellspacing="0"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;Table&lt;/TD&gt;&lt;TD&gt;#Rows&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Data_1&lt;/TD&gt;&lt;TD&gt;40&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Data_2&lt;/TD&gt;&lt;TD&gt;30&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Data_3&lt;/TD&gt;&lt;TD&gt;230&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;i can simply do like this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Proc sql;&lt;/P&gt;&lt;P&gt;create table ds.report&amp;nbsp; as&lt;/P&gt;&lt;P&gt;select '&lt;SPAN&gt;Data_1' as Table, count(*) from ds.Data_1&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;union&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;select 'Data_1' as Table, count(*) from ds.Data_2&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;union&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;select 'Data_1' as Table, count(*) from ds.Data_3;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;quit;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;this solution basic school level and okay for small count of file. but i looking for&amp;nbsp;simple code.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;eg: I can easily do this in qlikview.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Report:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Load&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Select tablename() as Table, count(*) from&amp;nbsp;Data_*;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Looking forward your advise for this case.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Best,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Robert&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 24 Nov 2017 08:59:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-automatically-count-rows-of-multiple-data-set-and-store/m-p/415951#M280175</guid>
      <dc:creator>robert_bos</dc:creator>
      <dc:date>2017-11-24T08:59:54Z</dc:date>
    </item>
    <item>
      <title>Re: How to automatically count #rows of multiple data set and store each data set count in table</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-automatically-count-rows-of-multiple-data-set-and-store/m-p/415955#M280176</link>
      <description>Try this&lt;BR /&gt;&lt;BR /&gt;proc sql;&lt;BR /&gt;create table xyz as&lt;BR /&gt;select memname,nobs from dictionary.tables where upcase(libname)='WORK' and upcase(Memname) in ('DATA_1','DATA_2','DATA_3');&lt;BR /&gt;quit;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Fri, 24 Nov 2017 09:13:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-automatically-count-rows-of-multiple-data-set-and-store/m-p/415955#M280176</guid>
      <dc:creator>RM6</dc:creator>
      <dc:date>2017-11-24T09:13:47Z</dc:date>
    </item>
    <item>
      <title>Re: How to automatically count #rows of multiple data set and store each data set count in table</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-automatically-count-rows-of-multiple-data-set-and-store/m-p/415963#M280177</link>
      <description>&lt;P&gt;Per&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/179384"&gt;@RM6&lt;/a&gt;&amp;nbsp;great answer, the answer to your question is simply that you do not need to.&amp;nbsp; SAS has its own internal metadata tables, which you can find in SASHELP library.&amp;nbsp; VTABLE contains information on all the tables in all the libraries that have been set, and VCOLUMN for all the columns within them, so you can simply query those tables, or in fact the dictionary syntax in SQL also relates to these:&lt;/P&gt;
&lt;P&gt;&lt;A href="http://www2.sas.com/proceedings/sugi30/070-30.pdf" target="_blank"&gt;http://www2.sas.com/proceedings/sugi30/070-30.pdf&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;So datastep would be:&lt;/P&gt;
&lt;PRE&gt;data want;
  set sashelp.vtable (where=(libname="YOURLIB" and substr(memname,1,5)="DATA"));
run;&lt;/PRE&gt;
&lt;P&gt;I would also really advise against using reserved words (data in this case) as a dataset name.&amp;nbsp; It both looks odd, and doesn't provide any information, we know its data, its a dataset, what does it contain!&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 24 Nov 2017 09:25:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-automatically-count-rows-of-multiple-data-set-and-store/m-p/415963#M280177</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2017-11-24T09:25:24Z</dc:date>
    </item>
    <item>
      <title>Re: How to automatically count #rows of multiple data set and store each data set count in table</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-automatically-count-rows-of-multiple-data-set-and-store/m-p/415981#M280178</link>
      <description>&lt;P&gt;Many thanks for your prompt answer.&lt;/P&gt;</description>
      <pubDate>Fri, 24 Nov 2017 10:22:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-automatically-count-rows-of-multiple-data-set-and-store/m-p/415981#M280178</guid>
      <dc:creator>robert_bos</dc:creator>
      <dc:date>2017-11-24T10:22:50Z</dc:date>
    </item>
    <item>
      <title>Re: How to automatically count #rows of multiple data set and store each data set count in table</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-automatically-count-rows-of-multiple-data-set-and-store/m-p/415982#M280179</link>
      <description>&lt;P&gt;Aamzing.&lt;/P&gt;</description>
      <pubDate>Fri, 24 Nov 2017 10:25:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-automatically-count-rows-of-multiple-data-set-and-store/m-p/415982#M280179</guid>
      <dc:creator>robert_bos</dc:creator>
      <dc:date>2017-11-24T10:25:18Z</dc:date>
    </item>
    <item>
      <title>Re: How to automatically count #rows of multiple data set and store each data set count in table</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-automatically-count-rows-of-multiple-data-set-and-store/m-p/415985#M280180</link>
      <description>&lt;P&gt;&lt;STRONG&gt;I would also really advise against using reserved words (data in this case) as a dataset name.&amp;nbsp; It both looks odd, and doesn't provide any information, we know its data, its a dataset, what does it contain!&amp;nbsp;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;hahaha.&amp;nbsp; I just give it for an example but real name is different. thanks for your advise.&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Best,&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Robert&lt;/STRONG&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 24 Nov 2017 10:35:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-automatically-count-rows-of-multiple-data-set-and-store/m-p/415985#M280180</guid>
      <dc:creator>robert_bos</dc:creator>
      <dc:date>2017-11-24T10:35:02Z</dc:date>
    </item>
    <item>
      <title>Re: How to automatically count #rows of multiple data set and store each data set count in table</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-automatically-count-rows-of-multiple-data-set-and-store/m-p/417014#M280181</link>
      <description>&lt;P&gt;Just be aware that using dictionary tables would not work for tables where the SAS engine does not have access to the number of rows in the table. This would be the case for database tables, and also SAS views of SAS tables. You would need to use count(*), or equivalent, in these cases.&lt;/P&gt;</description>
      <pubDate>Wed, 29 Nov 2017 11:29:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-automatically-count-rows-of-multiple-data-set-and-store/m-p/417014#M280181</guid>
      <dc:creator>lethcons</dc:creator>
      <dc:date>2017-11-29T11:29:48Z</dc:date>
    </item>
  </channel>
</rss>

