<?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: delete a data set if number of rows=0 in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/delete-a-data-set-if-number-of-rows-0/m-p/614322#M179547</link>
    <description>&lt;P&gt;Without stop, the data step would read the whole dataset, which is not necessary and would be a waste of time and resources.&lt;/P&gt;</description>
    <pubDate>Sun, 29 Dec 2019 21:57:27 GMT</pubDate>
    <dc:creator>Kurt_Bremser</dc:creator>
    <dc:date>2019-12-29T21:57:27Z</dc:date>
    <item>
      <title>delete a data set if number of rows=0</title>
      <link>https://communities.sas.com/t5/SAS-Programming/delete-a-data-set-if-number-of-rows-0/m-p/614296#M179532</link>
      <description>&lt;P&gt;Hello&lt;/P&gt;
&lt;P&gt;What is the way to delete a data set if number of rows=0 ?&lt;/P&gt;</description>
      <pubDate>Sun, 29 Dec 2019 17:52:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/delete-a-data-set-if-number-of-rows-0/m-p/614296#M179532</guid>
      <dc:creator>Ronein</dc:creator>
      <dc:date>2019-12-29T17:52:06Z</dc:date>
    </item>
    <item>
      <title>Re: delete a data set if number of rows=0</title>
      <link>https://communities.sas.com/t5/SAS-Programming/delete-a-data-set-if-number-of-rows-0/m-p/614300#M179535</link>
      <description>&lt;P&gt;The number of observations is stored in column nobs in dictionary.tables (SQL).&lt;/P&gt;
&lt;P&gt;Once you have a dataset with dataset names, you can use call execute from that dataset to create a proc delete step.&lt;/P&gt;</description>
      <pubDate>Sun, 29 Dec 2019 18:00:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/delete-a-data-set-if-number-of-rows-0/m-p/614300#M179535</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2019-12-29T18:00:48Z</dc:date>
    </item>
    <item>
      <title>Re: delete a data set if number of rows=0</title>
      <link>https://communities.sas.com/t5/SAS-Programming/delete-a-data-set-if-number-of-rows-0/m-p/614302#M179537</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159549"&gt;@Ronein&lt;/a&gt;&amp;nbsp; &amp;nbsp;Here is a demo&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/*Create a sample with 0 rows*/
data w;
stop;
set sashelp.class;
run;

/*Solution*/
%macro t;
data _null_;
 call symputx('n',n);
 stop;
 set w nobs=n;
run;
%put &amp;amp;n;
%if &amp;amp;n=0 %then %do;
 proc delete data=w;
 run;
%end;
%mend t;

%t

&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 29 Dec 2019 18:18:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/delete-a-data-set-if-number-of-rows-0/m-p/614302#M179537</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2019-12-29T18:18:24Z</dc:date>
    </item>
    <item>
      <title>Re: delete a data set if number of rows=0</title>
      <link>https://communities.sas.com/t5/SAS-Programming/delete-a-data-set-if-number-of-rows-0/m-p/614304#M179539</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data h;
	set sashelp.class;
	stop;
run;


%let id=%sysfunc(open(h));
%let nobs=%sysfunc(attrn(&amp;amp;id,nobs));
%let cl=%sysfunc(close(&amp;amp;id));

%put &amp;amp;=nobs;


%macro chck;
%if &amp;amp;nobs eq 0 %then %do;
	proc delete data=h;
	run;
%end;
%mend;

%chck&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 29 Dec 2019 18:40:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/delete-a-data-set-if-number-of-rows-0/m-p/614304#M179539</guid>
      <dc:creator>r_behata</dc:creator>
      <dc:date>2019-12-29T18:40:26Z</dc:date>
    </item>
    <item>
      <title>Re: delete a data set if number of rows=0</title>
      <link>https://communities.sas.com/t5/SAS-Programming/delete-a-data-set-if-number-of-rows-0/m-p/614317#M179542</link>
      <description>&lt;P&gt;Thank you.&lt;/P&gt;
&lt;P&gt;In&amp;nbsp; the macro that you create I didn't see using of the macro variables "ID"&amp;nbsp; and "cl".&lt;/P&gt;
&lt;P&gt;May you explain please why did you create them and where did you use them in order to delete data set with 0 observations?&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 29 Dec 2019 20:33:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/delete-a-data-set-if-number-of-rows-0/m-p/614317#M179542</guid>
      <dc:creator>Ronein</dc:creator>
      <dc:date>2019-12-29T20:33:23Z</dc:date>
    </item>
    <item>
      <title>Re: delete a data set if number of rows=0</title>
      <link>https://communities.sas.com/t5/SAS-Programming/delete-a-data-set-if-number-of-rows-0/m-p/614318#M179543</link>
      <description>&lt;P&gt;May you please explain the need of "STOP"&amp;nbsp; in your code?&lt;/P&gt;
&lt;P&gt;I know that nobs is automatic variable that contains number of rows in data set names in set statement.&lt;/P&gt;
&lt;P&gt;I understand that&amp;nbsp; in code nobs=n we place the value of nobs in variable n.&lt;/P&gt;
&lt;P&gt;I also understand that using&amp;nbsp;&lt;CODE class="  language-sas"&gt;call &lt;SPAN class="token function"&gt;symputx we put the value of variable n in&amp;nbsp; a macro variable called also n.&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/P&gt;
&lt;P&gt;&lt;CODE class="  language-sas"&gt;&lt;SPAN class="token function"&gt;Why do we need to use "Stop"?&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE class=" language-sas"&gt;&lt;CODE class="  language-sas"&gt;&lt;SPAN class="token procnames"&gt;data&lt;/SPAN&gt; _null_&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;
 call &lt;SPAN class="token function"&gt;symputx&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt;&lt;SPAN class="token string"&gt;'n'&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;,&lt;/SPAN&gt;&lt;SPAN class="token function"&gt;n&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;
 stop&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;
 &lt;SPAN class="token keyword"&gt;set&lt;/SPAN&gt; w nobs&lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt;&lt;SPAN class="token function"&gt;n&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;
&lt;SPAN class="token procnames"&gt;run&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 29 Dec 2019 20:48:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/delete-a-data-set-if-number-of-rows-0/m-p/614318#M179543</guid>
      <dc:creator>Ronein</dc:creator>
      <dc:date>2019-12-29T20:48:17Z</dc:date>
    </item>
    <item>
      <title>Re: delete a data set if number of rows=0</title>
      <link>https://communities.sas.com/t5/SAS-Programming/delete-a-data-set-if-number-of-rows-0/m-p/614322#M179547</link>
      <description>&lt;P&gt;Without stop, the data step would read the whole dataset, which is not necessary and would be a waste of time and resources.&lt;/P&gt;</description>
      <pubDate>Sun, 29 Dec 2019 21:57:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/delete-a-data-set-if-number-of-rows-0/m-p/614322#M179547</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2019-12-29T21:57:27Z</dc:date>
    </item>
    <item>
      <title>Re: delete a data set if number of rows=0</title>
      <link>https://communities.sas.com/t5/SAS-Programming/delete-a-data-set-if-number-of-rows-0/m-p/614323#M179548</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159549"&gt;@Ronein&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Thank you.&lt;/P&gt;
&lt;P&gt;In&amp;nbsp; the macro that you create I didn't see using of the macro variables "ID"&amp;nbsp; and "cl".&lt;/P&gt;
&lt;P&gt;May you explain please why did you create them and where did you use them in order to delete data set with 0 observations?&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;id is used in the attrn function, cl is needed to receive the return value of the close function. It has no other use.&lt;/P&gt;</description>
      <pubDate>Sun, 29 Dec 2019 22:00:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/delete-a-data-set-if-number-of-rows-0/m-p/614323#M179548</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2019-12-29T22:00:15Z</dc:date>
    </item>
  </channel>
</rss>

