<?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: SET data sets without data sets with zero rows in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/SET-data-sets-without-data-sets-with-zero-rows/m-p/875759#M346034</link>
    <description>&lt;P&gt;Since datasets with zero observations will not contribute any observations to the result anyway, this is not necessary. In fact, I find it even better to have the zero observations documented in the log, than not seeing a particular dataset there.&lt;/P&gt;</description>
    <pubDate>Mon, 15 May 2023 08:46:47 GMT</pubDate>
    <dc:creator>Kurt_Bremser</dc:creator>
    <dc:date>2023-05-15T08:46:47Z</dc:date>
    <item>
      <title>SET data sets without data sets with zero rows</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SET-data-sets-without-data-sets-with-zero-rows/m-p/875750#M346029</link>
      <description>&lt;P&gt;Hello&lt;/P&gt;
&lt;P&gt;I would like to create dynamic sas program that SET multiple data sets (from fixed list of data sets).&lt;/P&gt;
&lt;P&gt;The requirement is that If data set has zero rows then this data set will not be in SET statement.&lt;/P&gt;
&lt;P&gt;What is the way to do it please?&lt;/P&gt;
&lt;P&gt;In this example data set "wanted"&amp;nbsp; will be result of setting data sets:tbl2 and tbl3&lt;/P&gt;
&lt;P&gt;Please notr that the reason that I dont want to include data set with zero rows in the set statement is that I dont want&amp;nbsp; to get variables from empty data set in the wanted data set.&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data tbl1;
set sashelp.iris;
stop;
z=PetalLength-10;
run;

data tbl2;
set sashelp.iris;
X=SepalWidth*100;
W=PetalLength*10;
run;

data tbl3;
set sashelp.iris(obs=10);
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 15 May 2023 07:51:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SET-data-sets-without-data-sets-with-zero-rows/m-p/875750#M346029</guid>
      <dc:creator>Ronein</dc:creator>
      <dc:date>2023-05-15T07:51:27Z</dc:date>
    </item>
    <item>
      <title>Re: SET data sets without data sets with zero rows</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SET-data-sets-without-data-sets-with-zero-rows/m-p/875759#M346034</link>
      <description>&lt;P&gt;Since datasets with zero observations will not contribute any observations to the result anyway, this is not necessary. In fact, I find it even better to have the zero observations documented in the log, than not seeing a particular dataset there.&lt;/P&gt;</description>
      <pubDate>Mon, 15 May 2023 08:46:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SET-data-sets-without-data-sets-with-zero-rows/m-p/875759#M346034</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2023-05-15T08:46:47Z</dc:date>
    </item>
    <item>
      <title>Re: SET data sets without data sets with zero rows</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SET-data-sets-without-data-sets-with-zero-rows/m-p/875828#M346066</link>
      <description>&lt;P&gt;Let's say you have all these datasets in WORK library. We can use &lt;STRONG&gt;sashelp.vtable&lt;/STRONG&gt; to subset datasets based on &lt;STRONG&gt;nobs.&lt;/STRONG&gt;&amp;nbsp;The idea is importing all datasets name with obs &amp;gt;0 into a macro variable for further use.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Eg:&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
	set sashelp.vtable end=eof;
	where libname eq 'WORK' and nobs&amp;gt;0;
	length datasets $ 200;
	retain datasets;
	datasets= catx(" ", datasets, memname); 
	if eof then do; 
		call symputx('list', datasets);
	end;
run; 
%put &amp;amp;=list;&lt;BR /&gt;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="tables.PNG" style="width: 631px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/83980i5A808AA98FF5FB43/image-size/large?v=v2&amp;amp;px=999" role="button" title="tables.PNG" alt="tables.PNG" /&gt;&lt;/span&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Capture.PNG" style="width: 855px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/83979i2BD9DFFA078F50EA/image-size/large?v=v2&amp;amp;px=999" role="button" title="Capture.PNG" alt="Capture.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
	set &amp;amp;list;
run; &lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 15 May 2023 14:45:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SET-data-sets-without-data-sets-with-zero-rows/m-p/875828#M346066</guid>
      <dc:creator>A_Kh</dc:creator>
      <dc:date>2023-05-15T14:45:56Z</dc:date>
    </item>
    <item>
      <title>Re: SET data sets without data sets with zero rows</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SET-data-sets-without-data-sets-with-zero-rows/m-p/875837#M346067</link>
      <description>&lt;P&gt;Usually the best approach is to know which variables you want to keep, and list them on a KEEP statement or option.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;That said, if you have a function-style macro like %AnyObs (see &lt;A href="https://support.sas.com/resources/papers/proceedings/proceedings/sugi26/p095-26.pdf" target="_blank"&gt;https://support.sas.com/resources/papers/proceedings/proceedings/sugi26/p095-26.pdf&lt;/A&gt;&amp;nbsp;), then you can use that in an %IF statement to decide whether or not to list a dataset on the SET statement, e.g.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want ;
  set _null_  /*protect against reading _last_ if none of below datasets have records*/
    %if %anyobs(tbl1) %then %do ; tbl1 %end ;
    %if %anyobs(tbl2) %then %do ; tbl2 %end ;
    %if %anyobs(tbl3) %then %do ; tbl3 %end ;
  ;
run ;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 15 May 2023 15:29:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SET-data-sets-without-data-sets-with-zero-rows/m-p/875837#M346067</guid>
      <dc:creator>Quentin</dc:creator>
      <dc:date>2023-05-15T15:29:51Z</dc:date>
    </item>
    <item>
      <title>Re: SET data sets without data sets with zero rows</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SET-data-sets-without-data-sets-with-zero-rows/m-p/875928#M346095</link>
      <description>&lt;P&gt;Will data sets with zero observations contribute to columns list?&lt;/P&gt;
&lt;P&gt;I dont want to have columns that appear in data set with zero obs and dont appear in other data sets&lt;/P&gt;</description>
      <pubDate>Tue, 16 May 2023 07:08:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SET-data-sets-without-data-sets-with-zero-rows/m-p/875928#M346095</guid>
      <dc:creator>Ronein</dc:creator>
      <dc:date>2023-05-16T07:08:14Z</dc:date>
    </item>
  </channel>
</rss>

