<?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 print IF data set empty in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/print-IF-data-set-empty/m-p/828954#M327478</link>
    <description>&lt;P&gt;Hello&lt;/P&gt;
&lt;P&gt;I want to print a message in results window If the data set is empty .&lt;/P&gt;
&lt;P&gt;I also want to add title to&amp;nbsp; print in case that data set not empty.&lt;/P&gt;
&lt;P&gt;Error:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;75 call execute(Title 'information class_tbl';'proc print data=work.class_tbl2 noobs; run;');&lt;BR /&gt;_______________________ ______________________________________________&lt;BR /&gt;388 180&lt;BR /&gt;200&lt;BR /&gt;ERROR 388-185: Expecting an arithmetic operator.&lt;/P&gt;
&lt;P&gt;ERROR 180-322: Statement is not valid or it is used out of proper order.&lt;/P&gt;
&lt;P&gt;ERROR 200-322: The symbol is not recognized and will be ignored.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data class_tbl;
set sashelp.class;
run;

data class_tbl2;
set sashelp.class;
run;
proc sql noprint;
delete from work.class_tbl2
where Age &amp;lt; 20;
quit;
 


data use_this_if_no_obs;
msg='No Data';
run;

data _null_;
dsnid=open('work.class_tbl');

if dsnid then do;
nobs=attrn(dsnid, 'nobs');
end;

if nobs=0 then do;
call execute(Title 'information class_tbl'; 'proc print data=use_this_if_no_obs noobs; run;');
end;

else do;
call execute('proc print data=work.class_tbl  noobs; run;');
end;

rc = close(dsnid);
run;


data _null_;
dsnid=open('work.class_tbl2');

if dsnid then do;
nobs=attrn(dsnid, 'nobs');
end;

if nobs=0 then do;
call execute('proc print data=use_this_if_no_obs noobs; run;');
end;

else do;
call execute(Title 'information class_tbl';'proc print data=work.class_tbl2  noobs; run;');
end;

rc = close(dsnid);
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 17 Aug 2022 04:41:51 GMT</pubDate>
    <dc:creator>Ronein</dc:creator>
    <dc:date>2022-08-17T04:41:51Z</dc:date>
    <item>
      <title>print IF data set empty</title>
      <link>https://communities.sas.com/t5/SAS-Programming/print-IF-data-set-empty/m-p/828954#M327478</link>
      <description>&lt;P&gt;Hello&lt;/P&gt;
&lt;P&gt;I want to print a message in results window If the data set is empty .&lt;/P&gt;
&lt;P&gt;I also want to add title to&amp;nbsp; print in case that data set not empty.&lt;/P&gt;
&lt;P&gt;Error:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;75 call execute(Title 'information class_tbl';'proc print data=work.class_tbl2 noobs; run;');&lt;BR /&gt;_______________________ ______________________________________________&lt;BR /&gt;388 180&lt;BR /&gt;200&lt;BR /&gt;ERROR 388-185: Expecting an arithmetic operator.&lt;/P&gt;
&lt;P&gt;ERROR 180-322: Statement is not valid or it is used out of proper order.&lt;/P&gt;
&lt;P&gt;ERROR 200-322: The symbol is not recognized and will be ignored.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data class_tbl;
set sashelp.class;
run;

data class_tbl2;
set sashelp.class;
run;
proc sql noprint;
delete from work.class_tbl2
where Age &amp;lt; 20;
quit;
 


data use_this_if_no_obs;
msg='No Data';
run;

data _null_;
dsnid=open('work.class_tbl');

if dsnid then do;
nobs=attrn(dsnid, 'nobs');
end;

if nobs=0 then do;
call execute(Title 'information class_tbl'; 'proc print data=use_this_if_no_obs noobs; run;');
end;

else do;
call execute('proc print data=work.class_tbl  noobs; run;');
end;

rc = close(dsnid);
run;


data _null_;
dsnid=open('work.class_tbl2');

if dsnid then do;
nobs=attrn(dsnid, 'nobs');
end;

if nobs=0 then do;
call execute('proc print data=use_this_if_no_obs noobs; run;');
end;

else do;
call execute(Title 'information class_tbl';'proc print data=work.class_tbl2  noobs; run;');
end;

rc = close(dsnid);
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 17 Aug 2022 04:41:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/print-IF-data-set-empty/m-p/828954#M327478</guid>
      <dc:creator>Ronein</dc:creator>
      <dc:date>2022-08-17T04:41:51Z</dc:date>
    </item>
    <item>
      <title>Re: print IF data set empty</title>
      <link>https://communities.sas.com/t5/SAS-Programming/print-IF-data-set-empty/m-p/828956#M327479</link>
      <description>&lt;P&gt;To conditionally execute code, use %IF %THEN %DO %END %ELSE %DO %END. CALL EXECUTE is good if you need to create code from data step values, but for a simpke yes/no decision macro language is easier. Retrieve the number of observations in PROC SQL with SELECT INTO from DICTIONARY.TABLES.&lt;/P&gt;
&lt;P&gt;The word title without quotes around it in your call execute is interpreted by the data step compiler as a variable name.&lt;/P&gt;</description>
      <pubDate>Wed, 17 Aug 2022 05:30:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/print-IF-data-set-empty/m-p/828956#M327479</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2022-08-17T05:30:16Z</dc:date>
    </item>
  </channel>
</rss>

