<?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: Printing Message if Dataset is Empty in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Printing-Message-if-Dataset-is-Empty/m-p/835417#M330288</link>
    <description>&lt;P&gt;The values of LIBNAME and MEMNAME in the various dictionary tables are always in uppercase. Searching for a member name with lowercase letters will never match.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But if you know the input dataset exists then you can use a simple data step to check if it has observations or not. No need to search the dictionary metadata tables.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
  if nobs then call execute('proc print data=log2_trimm; run;');
  else call execute('proc print data=use_this_if_no_obs; run;');
  stop;
  set log2_trimm nobs=nobs;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Tue, 27 Sep 2022 12:36:53 GMT</pubDate>
    <dc:creator>Tom</dc:creator>
    <dc:date>2022-09-27T12:36:53Z</dc:date>
    <item>
      <title>Printing Message if Dataset is Empty</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Printing-Message-if-Dataset-is-Empty/m-p/835414#M330286</link>
      <description>&lt;P&gt;I know this has been asked a couple times before, but whatever method I try, I can't get this to work.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have a dataset named&lt;STRONG&gt; log2_trimm&lt;/STRONG&gt;, containing trimmed error messages that were found in log .txt files. If no errors are found in that file, the dataset is created and sits empty. If it does contain observations, it is printed as a list I can read through. I use this for knowing when crosstabulations aren't performed due to empty cells.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I've tried variations of this approach, which I found on another SAS Communities question solution:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;	data  use_this_if_no_obs;
	  msg='No Empty Cells';
	run;

	data _null_;
		set sashelp.vtable (where=(libname="WORK" and memname="log2_trimm"));
	  		if nobs=0 then call execute('proc print data=use_this_if_no_obs; run;');
	  		Else if nobs GE 1 then call execute('proc print data=log2_trimm; run;');
	run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;I only get the error message:&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;4020 data use_this_if_no_obs;&lt;BR /&gt;4021 msg='No Data';&lt;BR /&gt;4022 run;&lt;/P&gt;
&lt;P&gt;NOTE: The data set WORK.USE_THIS_IF_NO_OBS has 1 observations and 1 variables.&lt;BR /&gt;NOTE: DATA statement used (Total process time):&lt;BR /&gt;real time 0.03 seconds&lt;BR /&gt;cpu time 0.03 seconds&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;4023&lt;BR /&gt;4024 data _null_;&lt;BR /&gt;4025 set sashelp.vtable (where=(libname="WORK" and memname="log2_trimm"));&lt;BR /&gt;4026 if nobs=0 then call execute('proc print data=use_this_if_no_obs; run;');&lt;BR /&gt;4027 Else if nobs GE 1 then call execute('proc print data=log2_trimm; run;');&lt;BR /&gt;4028 run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;NOTE: Data file SASUSER.SASMBC.DATA is in a format that is native to another host, or the file&lt;BR /&gt;encoding does not match the session encoding. Cross Environment Data Access will be used,&lt;BR /&gt;which might require additional CPU resources and might reduce performance.&lt;BR /&gt;NOTE: There were 0 observations read from the data set SASHELP.VTABLE.&lt;BR /&gt;WHERE (libname='WORK') and (memname='log2_trimm');&lt;BR /&gt;NOTE: DATA statement used (Total process time):&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;I know the log2_trimm dataset exists; SAS and I both know it's empty. I also see it in the VTABLE with zero observations.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;What gives? What am I doing wrong? I've even tried variations of this, even tried Proc SQL, and it just refuses to print the message.&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>Tue, 27 Sep 2022 12:10:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Printing-Message-if-Dataset-is-Empty/m-p/835414#M330286</guid>
      <dc:creator>SAS93</dc:creator>
      <dc:date>2022-09-27T12:10:44Z</dc:date>
    </item>
    <item>
      <title>Re: Printing Message if Dataset is Empty</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Printing-Message-if-Dataset-is-Empty/m-p/835416#M330287</link>
      <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/297876"&gt;@SAS93&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I don't see an error &lt;EM&gt;message&lt;/EM&gt;, but a logical error: The dataset names in SASHELP.VTABLE are written in upper case, so your WHERE condition should read&lt;/P&gt;
&lt;PRE&gt;libname="WORK" and memname="&lt;FONT color="#3366FF"&gt;&lt;STRONG&gt;LOG2_TRIMM&lt;/STRONG&gt;&lt;/FONT&gt;"&lt;/PRE&gt;</description>
      <pubDate>Tue, 27 Sep 2022 12:20:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Printing-Message-if-Dataset-is-Empty/m-p/835416#M330287</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2022-09-27T12:20:51Z</dc:date>
    </item>
    <item>
      <title>Re: Printing Message if Dataset is Empty</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Printing-Message-if-Dataset-is-Empty/m-p/835417#M330288</link>
      <description>&lt;P&gt;The values of LIBNAME and MEMNAME in the various dictionary tables are always in uppercase. Searching for a member name with lowercase letters will never match.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But if you know the input dataset exists then you can use a simple data step to check if it has observations or not. No need to search the dictionary metadata tables.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
  if nobs then call execute('proc print data=log2_trimm; run;');
  else call execute('proc print data=use_this_if_no_obs; run;');
  stop;
  set log2_trimm nobs=nobs;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 27 Sep 2022 12:36:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Printing-Message-if-Dataset-is-Empty/m-p/835417#M330288</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2022-09-27T12:36:53Z</dc:date>
    </item>
    <item>
      <title>Re: Printing Message if Dataset is Empty</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Printing-Message-if-Dataset-is-Empty/m-p/835418#M330289</link>
      <description>&lt;P&gt;THANK YOU, that solved the problem! I did not realize working with the dictionary tables was case-sensitive.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 27 Sep 2022 12:40:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Printing-Message-if-Dataset-is-Empty/m-p/835418#M330289</guid>
      <dc:creator>SAS93</dc:creator>
      <dc:date>2022-09-27T12:40:04Z</dc:date>
    </item>
  </channel>
</rss>

