<?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: PROC DATASETS on empty library in ODS and Base Reporting</title>
    <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/PROC-DATASETS-on-empty-library/m-p/870480#M26264</link>
    <description>&lt;P&gt;Instead of PROC DATASETS, use DICTIONARY.TABLES in SQL or SASHELP.VTABLE to scan for datasets:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;  
set sashelp.vtable;  
where libname = "MYSCHEMA" and memname = "TEST";
call execute(cats('proc delete data=',libname,'.',memname,';run;'));
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 19 Apr 2023 05:55:43 GMT</pubDate>
    <dc:creator>Kurt_Bremser</dc:creator>
    <dc:date>2023-04-19T05:55:43Z</dc:date>
    <item>
      <title>PROC DATASETS on empty library</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/PROC-DATASETS-on-empty-library/m-p/870431#M26261</link>
      <description>&lt;P&gt;We have a bit of code (see below) that will output to a table in the work library a list of all tables in a user specific schema. Then will delete a table if it exists. This bit of code works well if the user's schema has tables in it, however some users are new and haven't created any tables so their schema is empty and PROC DATASETS generates the following warnings.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&lt;SPAN class="ui-provider gz b c d e f g h i j k l m n o p q r s t u v w x y z ab ac ae af ag ah ai aj ak"&gt;WARNING: No matching members in directory.&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&lt;SPAN class="ui-provider gz b c d e f g h i j k l m n o p q r s t u v w x y z ab ac ae af ag ah ai aj ak"&gt;WARNING: Output 'members' was not created.&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;How do I create and empty table, but with the same column names, when there are no members. Or is there a better way to generate a table full of dataset names for occupied and empty libraries.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;libname MySchema oracle authdomain=oracle_auth path=database;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;**List out Tables in &lt;SPAN&gt;MySchema&lt;/SPAN&gt; to delete table if it exists;&lt;BR /&gt;ods output members=my_tables;&lt;BR /&gt;proc datasets library=&lt;SPAN&gt;MySchema&lt;/SPAN&gt;;&lt;BR /&gt;quit;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data _null_;&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;set &lt;SPAN&gt;my_tables&lt;/SPAN&gt;;&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;if upper(name) eq '&lt;SPAN&gt;TEST&lt;/SPAN&gt;' then do;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;call execute('proc delete data=&lt;SPAN&gt;MySchema&lt;/SPAN&gt;.TEST;run;');&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;end;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 18 Apr 2023 19:46:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/PROC-DATASETS-on-empty-library/m-p/870431#M26261</guid>
      <dc:creator>ErinKSimmons</dc:creator>
      <dc:date>2023-04-18T19:46:23Z</dc:date>
    </item>
    <item>
      <title>Re: PROC DATASETS on empty library</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/PROC-DATASETS-on-empty-library/m-p/870443#M26262</link>
      <description>&lt;P&gt;I don't think there is an easy way to get ODS OUTPUT to create a 0 obs output dataset instead of not creating an output dataset.&amp;nbsp; And also don't think there is a way to suppress the warning message.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;PROC CONTENTS with an OUT= option will create a 0 obs dataset, but it also throws a warning.&lt;/P&gt;
&lt;PRE&gt;1    proc contents data=empty._all_ out=foo;
2    run ;

WARNING: No matching members in directory.
NOTE: The data set WORK.FOO has 0 observations and 41 variables.
&lt;/PRE&gt;
&lt;P&gt;If your goal is to basically do "if table exists then delete", maybe you could use PROC DATASETS to do the delete. With the NOWARN option it doesn't complain if a dataset doesn't exist.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;libname empty "Q:\junk\empty" ;

proc datasets library=empty nolist nowarn;
  delete test;
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Or, since PROC DELETE is often faster than PROC DATASETS, you could use a macro like (untested):&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro deleteifexists(data) ;
  %if %sysfunc(exist(&amp;amp;data)) %then %do ;
    proc delete data=&amp;amp;data ;
    run ;
  %end ;
%mend deleteifexists ;

%deleteifexists(empty.test)&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 18 Apr 2023 21:16:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/PROC-DATASETS-on-empty-library/m-p/870443#M26262</guid>
      <dc:creator>Quentin</dc:creator>
      <dc:date>2023-04-18T21:16:59Z</dc:date>
    </item>
    <item>
      <title>Re: PROC DATASETS on empty library</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/PROC-DATASETS-on-empty-library/m-p/870458#M26263</link>
      <description>Thanks, I used the macro approach solution. Your untested macro worked, for the record.</description>
      <pubDate>Wed, 19 Apr 2023 00:34:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/PROC-DATASETS-on-empty-library/m-p/870458#M26263</guid>
      <dc:creator>ErinKSimmons</dc:creator>
      <dc:date>2023-04-19T00:34:59Z</dc:date>
    </item>
    <item>
      <title>Re: PROC DATASETS on empty library</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/PROC-DATASETS-on-empty-library/m-p/870480#M26264</link>
      <description>&lt;P&gt;Instead of PROC DATASETS, use DICTIONARY.TABLES in SQL or SASHELP.VTABLE to scan for datasets:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;  
set sashelp.vtable;  
where libname = "MYSCHEMA" and memname = "TEST";
call execute(cats('proc delete data=',libname,'.',memname,';run;'));
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 19 Apr 2023 05:55:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/PROC-DATASETS-on-empty-library/m-p/870480#M26264</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2023-04-19T05:55:43Z</dc:date>
    </item>
    <item>
      <title>Re: PROC DATASETS on empty library</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/PROC-DATASETS-on-empty-library/m-p/870529#M26265</link>
      <description>&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/19879"&gt;@Quentin&lt;/a&gt;&amp;nbsp;&lt;BR /&gt;No need a macro for PROC DELETE at all,&lt;BR /&gt;Just need one more option NODSNFRR .&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;options nodsnferr;&lt;BR /&gt;proc delete data=x;&lt;BR /&gt;run;</description>
      <pubDate>Wed, 19 Apr 2023 11:50:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/PROC-DATASETS-on-empty-library/m-p/870529#M26265</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2023-04-19T11:50:18Z</dc:date>
    </item>
    <item>
      <title>Re: PROC DATASETS on empty library</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/PROC-DATASETS-on-empty-library/m-p/870535#M26266</link>
      <description>&lt;P&gt;Thanks&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/18408"&gt;@Ksharp&lt;/a&gt;&amp;nbsp;, I didn't know about DSNFERR.&amp;nbsp; As I was thinking about this, I even thought "I wonder if there is something like DKRICOND=NOWARN but for datasets, bot variables" but I didn't bother to open up the documentation to look.&lt;/P&gt;</description>
      <pubDate>Wed, 19 Apr 2023 12:31:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/PROC-DATASETS-on-empty-library/m-p/870535#M26266</guid>
      <dc:creator>Quentin</dc:creator>
      <dc:date>2023-04-19T12:31:05Z</dc:date>
    </item>
  </channel>
</rss>

