<?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 recursively get the number of observation, looping through data sets in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-recursively-get-the-number-of-observation-looping-through/m-p/476673#M122682</link>
    <description>&lt;P&gt;oh.. just routine. By writing it this way I bypass a program that searches for warnings, errors and special notes in the log and I directly get to the section where the notification is raised when I search by myself&lt;/P&gt;</description>
    <pubDate>Tue, 10 Jul 2018 06:47:41 GMT</pubDate>
    <dc:creator>Oligolas</dc:creator>
    <dc:date>2018-07-10T06:47:41Z</dc:date>
    <item>
      <title>How to recursively get the number of observation, looping through data sets</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-recursively-get-the-number-of-observation-looping-through/m-p/476378#M122599</link>
      <description>&lt;P&gt;Hi everyone,&lt;/P&gt;&lt;P&gt;what I'm trying to achieve is&amp;nbsp;loop through some tables-data sets, getting the number of observation of each table.&lt;/P&gt;&lt;P&gt;So, suppose I’ve the following situation:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data tabl1;
	input name $ age;
	datalines;
	TOM 40
	TIM 50
	JIM 30
	JOHN 20
	;
run;
data tabl2;
	input surname $ city $;
	datalines;
	JOHNSON LONDON
	THOMPSON ROME
	STONE TORONTO
	;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Reading the various support forums, I’ve come across with this solution:&lt;/P&gt;&lt;P&gt;1. create a data set with the tables I want:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data tabs;
	set sashelp.vstable;
	where libname='WORK' and upcase(memname) contains 'TABL';
	tab_name=memname;
	keep tab_name;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;2. create an array with to loop in and get the number of observations from the descriptive&amp;nbsp;part of the data set:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
	set work.tabs nobs=n;
	call symput ('num_tab',n);
	call symput ('tab',"");	

run;

data test;
	array tables[&amp;amp;num_tab] $32767. _temporary_;
	if _N_=1 then do j=1 to number_of_obs;
		set work.tabs nobs=number_of_obs;
		tables[j]=tab_name;
	end;
	else go to end_p;
	do i=1 to dim(tables);
		call symputx (cats('tab'),tables[i]);
		if 0 then set work.&amp;amp;tab nobs=nob;
		n=nob;
		output;
	end;
	keep tab_name n;
end_p: run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Unfortunately I'm not getting the number of observation for each data set.&lt;/P&gt;&lt;P&gt;What I'm trying to achieve s this:&lt;/P&gt;&lt;PRE&gt;tab_name	n
TABL1		4
TABL2		3&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;What I'm doing wrong? Is this the best way to do it?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for the help!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;T&lt;/P&gt;</description>
      <pubDate>Mon, 09 Jul 2018 08:13:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-recursively-get-the-number-of-observation-looping-through/m-p/476378#M122599</guid>
      <dc:creator>tommymene86</dc:creator>
      <dc:date>2018-07-09T08:13:15Z</dc:date>
    </item>
    <item>
      <title>Re: How to recursively get the number of observation, looping through data sets</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-recursively-get-the-number-of-observation-looping-through/m-p/476403#M122605</link>
      <description>&lt;P&gt;Hi you can directly extract the number of observations from the SAS metadata. There is no need to Loop through them.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;DATA _NULL_;
   set sashelp.vtable(keep= libname memname nobs);
   where libname eq 'SASHELP' and memname eq 'CLASS';
   put 'W' 'ARNING: number of obs in ' libname= memname 'is ' nobs;
RUN;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 09 Jul 2018 11:52:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-recursively-get-the-number-of-observation-looping-through/m-p/476403#M122605</guid>
      <dc:creator>Oligolas</dc:creator>
      <dc:date>2018-07-09T11:52:31Z</dc:date>
    </item>
    <item>
      <title>Re: How to recursively get the number of observation, looping through data sets</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-recursively-get-the-number-of-observation-looping-through/m-p/476404#M122606</link>
      <description>&lt;P&gt;in your case:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;DATA _NULL_;
   set sashelp.vtable(keep= libname memname nobs);
   where libname eq 'WORK' and memname in ('TABL1','TABL2');
   put 'W' 'ARNING: number of obs in ' libname memname 'is ' nobs;
RUN;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 09 Jul 2018 11:59:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-recursively-get-the-number-of-observation-looping-through/m-p/476404#M122606</guid>
      <dc:creator>Oligolas</dc:creator>
      <dc:date>2018-07-09T11:59:54Z</dc:date>
    </item>
    <item>
      <title>Re: How to recursively get the number of observation, looping through data sets</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-recursively-get-the-number-of-observation-looping-through/m-p/476497#M122641</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/77163"&gt;@Oligolas&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;in your case:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;DATA _NULL_;
   set sashelp.vtable(keep= libname memname nobs);
   where libname eq 'WORK' and memname in ('TABL1','TABL2');
   put 'W' 'ARNING: number of obs in ' libname memname 'is ' nobs;
RUN;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/77163"&gt;@Oligolas&lt;/a&gt;&lt;/P&gt;
&lt;P&gt;May I ask why you use&lt;/P&gt;
&lt;P&gt;put 'W' 'ARNING: number of obs in '&lt;/P&gt;
&lt;P&gt;instead of&lt;/P&gt;
&lt;P&gt;put 'WARNING: number of obs in '&lt;/P&gt;
&lt;P&gt;?&lt;/P&gt;</description>
      <pubDate>Mon, 09 Jul 2018 15:42:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-recursively-get-the-number-of-observation-looping-through/m-p/476497#M122641</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2018-07-09T15:42:09Z</dc:date>
    </item>
    <item>
      <title>Re: How to recursively get the number of observation, looping through data sets</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-recursively-get-the-number-of-observation-looping-through/m-p/476525#M122648</link>
      <description>&lt;P&gt;So if you are searching a SASLOG for WARNING, the line of code that begins put 'W' isn't found by the search.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Similarly, you can do this for user generated ERROR statements that appear in the SASLOG.&lt;/P&gt;</description>
      <pubDate>Mon, 09 Jul 2018 17:01:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-recursively-get-the-number-of-observation-looping-through/m-p/476525#M122648</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2018-07-09T17:01:29Z</dc:date>
    </item>
    <item>
      <title>Re: How to recursively get the number of observation, looping through data sets</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-recursively-get-the-number-of-observation-looping-through/m-p/476673#M122682</link>
      <description>&lt;P&gt;oh.. just routine. By writing it this way I bypass a program that searches for warnings, errors and special notes in the log and I directly get to the section where the notification is raised when I search by myself&lt;/P&gt;</description>
      <pubDate>Tue, 10 Jul 2018 06:47:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-recursively-get-the-number-of-observation-looping-through/m-p/476673#M122682</guid>
      <dc:creator>Oligolas</dc:creator>
      <dc:date>2018-07-10T06:47:41Z</dc:date>
    </item>
  </channel>
</rss>

