<?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: How to export to excel a 0 observation data with a &amp;quot;No Data&amp;quot; note. in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-export-to-excel-a-0-observation-data-with-a-quot-No-Data/m-p/737625#M229985</link>
    <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/11562"&gt;@Kurt_Bremser&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This became available with SAS 9.4 M5 (maintenance release 5) sometime in spring 2018, both %IF-%THEN-%DO and %ELSE-%DO.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;See this blog post by &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/4"&gt;@ChrisHemedinger&lt;/a&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="arial,helvetica,sans-serif" size="4"&gt;&lt;A href="https://blogs.sas.com/content/sasdummy/2018/07/05/if-then-else-sas-programs/" target="_self"&gt;Using %IF-%THEN-%ELSE in SAS programs&lt;/A&gt;&lt;/FONT&gt;&lt;/P&gt;</description>
    <pubDate>Wed, 28 Apr 2021 15:50:41 GMT</pubDate>
    <dc:creator>LeonidBatkhan</dc:creator>
    <dc:date>2021-04-28T15:50:41Z</dc:date>
    <item>
      <title>How to export to excel a 0 observation data with a "No Data" note.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-export-to-excel-a-0-observation-data-with-a-quot-No-Data/m-p/737492#M229939</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have been trying to google a solution for this but have not had too much success. Hoping folks here can help.&lt;/P&gt;&lt;P&gt;I have a dataset with 0 observation.&lt;/P&gt;&lt;P&gt;I want to export that dataset into an excel sheet with a note that says "No data available".&lt;/P&gt;&lt;P&gt;How do I do this?&lt;/P&gt;&lt;P&gt;I am using proc report that I export into an excel sheet. Sometimes the dataset will have data in it and the export will populate the excel sheet, other times the dataset may have no data in it, in that case instead of sas not creating an excel sheet I still would like to create the excel sheet but have a note that says "No data available".&amp;nbsp; Incase, folks suggest a call and execute, I already have an execute that I run before the proc report&amp;nbsp;where I am adding a footnote. So if there is a suggestion to edit the below where if there is 0 observation then have a "No data note", otherwise run the below execute before the proc report, it will be helpful. Thank you!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
set have ;
if index(clinic,'*') then do;
call execute 
('footnote h=11pt justify=left font=Calibri color=black bold  "* Multiple clinics are reported here";');
stop;
end;
run;&lt;/CODE&gt;&lt;/PRE&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>Wed, 28 Apr 2021 05:50:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-export-to-excel-a-0-observation-data-with-a-quot-No-Data/m-p/737492#M229939</guid>
      <dc:creator>sas_student1</dc:creator>
      <dc:date>2021-04-28T05:50:32Z</dc:date>
    </item>
    <item>
      <title>Re: How to export to excel a 0 observation data with a "No Data" note.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-export-to-excel-a-0-observation-data-with-a-quot-No-Data/m-p/737495#M229940</link>
      <description>&lt;P&gt;I don't know how it is output in the proc report because I don't have the code, but it looks like you can control the content of the footnote by checking the number of observations and branching the process with %if statement.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
  set sashelp.vtable;
  where libname='WORK' and memname='HAVE';
  call symputx('nobs',nobs);
run;

data _null_;
%if &amp;amp;nobs=0 %then %do;
  call execute ('footnote h=11pt justify=left font=Calibri color=black bold  "No data available.";');
%end;
%else %do;
  set have ;
  if index(clinic,'*') then do;
  call execute ('footnote h=11pt justify=left font=Calibri color=black bold  "* Multiple clinics are reported here";');
  stop;
  end;
%end;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 28 Apr 2021 06:23:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-export-to-excel-a-0-observation-data-with-a-quot-No-Data/m-p/737495#M229940</guid>
      <dc:creator>japelin</dc:creator>
      <dc:date>2021-04-28T06:23:10Z</dc:date>
    </item>
    <item>
      <title>Re: How to export to excel a 0 observation data with a "No Data" note.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-export-to-excel-a-0-observation-data-with-a-quot-No-Data/m-p/737497#M229941</link>
      <description>&lt;P&gt;Try something like&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/* fake data */
data work.have;
   if 0 then set sashelp.class(rename=(name=clinic));
   stop;
run;

%global hasdata;

data _null_;
   if _nobs then do;      
      call symputx('hasdata', 'yes');
   end;
   else do;
      call symputx('hasdata', 'no');
   end;

   set have nobs=_nobs;
run;

%put &amp;amp;=hasdata;

ods excel file="&amp;amp;Benutzer\temp\empty.xlsx";

/* requires sas 9.4m5 or later */
%if &amp;amp;hasdata. = no %then %do;
   ods text="No data available";
%end;

proc report data=have;
   columns Age Weight Height;
   define Age / group;
   define Weight / median;
   define Height / max;
run;

ods excel close;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 28 Apr 2021 06:52:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-export-to-excel-a-0-observation-data-with-a-quot-No-Data/m-p/737497#M229941</guid>
      <dc:creator>andreas_lds</dc:creator>
      <dc:date>2021-04-28T06:52:18Z</dc:date>
    </item>
    <item>
      <title>Re: How to export to excel a 0 observation data with a "No Data" note.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-export-to-excel-a-0-observation-data-with-a-quot-No-Data/m-p/737499#M229942</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/226565"&gt;@japelin&lt;/a&gt;&amp;nbsp;this will no work:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
%if &amp;amp;nobs=0 %then %do;
  call execute ('footnote h=11pt justify=left font=Calibri color=black bold  "No data available.";');
%end;
%else %do;
  set have ;
  if index(clinic,'*') then do;
  call execute ('footnote h=11pt justify=left font=Calibri color=black bold  "* Multiple clinics are reported here";');
  stop;
  end;
%end;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;as you cannot use %ELSE in open code.&lt;/P&gt;
&lt;P&gt;But you can do this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%if &amp;amp;nobs. = 0
%then %do;
footnote h=11pt justify=left font=Calibri color=black bold  "No data available.";
%end;
%if &amp;amp;nobs. ne 0
%then %do;
data _null_;
set have ;
if index(clinic,'*')
then do;
  call execute ('footnote h=11pt justify=left font=Calibri color=black bold  "* Multiple clinics are reported here";');
  stop;
end;
run;
%end;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;One still has to decide what to do when no asterisk is found in the first observation, and how to activate the footnotes.&lt;/P&gt;
&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/103523"&gt;@sas_student1&lt;/a&gt;&amp;nbsp;Please post your complete REPORT code (including ODS statements for Excel), so we can see what you do when data is found; we can then make suggestions how to insert code for the "no data" situation.&lt;/P&gt;</description>
      <pubDate>Wed, 28 Apr 2021 07:07:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-export-to-excel-a-0-observation-data-with-a-quot-No-Data/m-p/737499#M229942</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2021-04-28T07:07:26Z</dc:date>
    </item>
    <item>
      <title>Re: How to export to excel a 0 observation data with a "No Data" note.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-export-to-excel-a-0-observation-data-with-a-quot-No-Data/m-p/737502#M229944</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/11562"&gt;@Kurt_Bremser&lt;/a&gt;&amp;nbsp;Thank you for pointing this out.&lt;BR /&gt;I had lost track of the fact that it was open code.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 28 Apr 2021 07:26:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-export-to-excel-a-0-observation-data-with-a-quot-No-Data/m-p/737502#M229944</guid>
      <dc:creator>japelin</dc:creator>
      <dc:date>2021-04-28T07:26:17Z</dc:date>
    </item>
    <item>
      <title>Re: How to export to excel a 0 observation data with a "No Data" note.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-export-to-excel-a-0-observation-data-with-a-quot-No-Data/m-p/737594#M229975</link>
      <description>&lt;P&gt;Hi &lt;A class="trigger-hovercard" style="color: #009999;" href="https://communities.sas.com/t5/user/viewprofilepage/user-id/11562" target="_blank"&gt;KurtBremser&lt;/A&gt;,&lt;/P&gt;
&lt;P&gt;Actually, you can use %else in open code (I believe, starting SAS 9.4 M5):&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let A=0;
%if &amp;amp;a=1 %then
%do;
   %put THEN;
%end;
%else
%do;
   %put ELSE;
%end;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 28 Apr 2021 14:50:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-export-to-excel-a-0-observation-data-with-a-quot-No-Data/m-p/737594#M229975</guid>
      <dc:creator>LeonidBatkhan</dc:creator>
      <dc:date>2021-04-28T14:50:37Z</dc:date>
    </item>
    <item>
      <title>Re: How to export to excel a 0 observation data with a "No Data" note.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-export-to-excel-a-0-observation-data-with-a-quot-No-Data/m-p/737616#M229982</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/51532"&gt;@LeonidBatkhan&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hi &lt;A class="trigger-hovercard" style="color: #009999;" href="https://communities.sas.com/t5/user/viewprofilepage/user-id/11562" target="_blank" rel="noopener"&gt;KurtBremser&lt;/A&gt;,&lt;/P&gt;
&lt;P&gt;Actually, you can use %else in open code (I believe, starting SAS 9.4 M5):&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let A=0;
%if &amp;amp;a=1 %then
%do;
   %put THEN;
%end;
%else
%do;
   %put ELSE;
%end;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;But there must have been a time when %IF %THEN was possible, but not the %ELSE?&lt;/P&gt;
&lt;P&gt;When exactly became %IF available in open code? The macro language reference in the documentation somehow does not show this, and I also didi not find a reference in the "What's new" section.&lt;/P&gt;</description>
      <pubDate>Wed, 28 Apr 2021 15:38:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-export-to-excel-a-0-observation-data-with-a-quot-No-Data/m-p/737616#M229982</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2021-04-28T15:38:39Z</dc:date>
    </item>
    <item>
      <title>Re: How to export to excel a 0 observation data with a "No Data" note.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-export-to-excel-a-0-observation-data-with-a-quot-No-Data/m-p/737618#M229983</link>
      <description>&lt;P&gt;Does it not create the sheet at all?&lt;/P&gt;
&lt;P&gt;Or does it create the sheet with column headers but no rows of data?&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If the later is there really any need to add something additional?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If the former then you probably just need to run a separate step to create the sheet you want to appear when there is no data.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please show the code you are currently using to write the sheet as the way to adjust the code depends on what code you are currently using..&lt;/P&gt;</description>
      <pubDate>Wed, 28 Apr 2021 15:43:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-export-to-excel-a-0-observation-data-with-a-quot-No-Data/m-p/737618#M229983</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2021-04-28T15:43:49Z</dc:date>
    </item>
    <item>
      <title>Re: How to export to excel a 0 observation data with a "No Data" note.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-export-to-excel-a-0-observation-data-with-a-quot-No-Data/m-p/737625#M229985</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/11562"&gt;@Kurt_Bremser&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This became available with SAS 9.4 M5 (maintenance release 5) sometime in spring 2018, both %IF-%THEN-%DO and %ELSE-%DO.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;See this blog post by &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/4"&gt;@ChrisHemedinger&lt;/a&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="arial,helvetica,sans-serif" size="4"&gt;&lt;A href="https://blogs.sas.com/content/sasdummy/2018/07/05/if-then-else-sas-programs/" target="_self"&gt;Using %IF-%THEN-%ELSE in SAS programs&lt;/A&gt;&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 28 Apr 2021 15:50:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-export-to-excel-a-0-observation-data-with-a-quot-No-Data/m-p/737625#M229985</guid>
      <dc:creator>LeonidBatkhan</dc:creator>
      <dc:date>2021-04-28T15:50:41Z</dc:date>
    </item>
    <item>
      <title>Re: How to export to excel a 0 observation data with a "No Data" note.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-export-to-excel-a-0-observation-data-with-a-quot-No-Data/m-p/737630#M229986</link>
      <description>&lt;P&gt;There is no need for the extra step to count the observations or the macro code. Use the NOBS option of the SET statement.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So your example reduces to :&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
  if nobs=0 then call execute('footnote h=11pt justify=left font=Calibri color=black bold "No data available.";');
  set have nobs=nobs;
  if index(clinic,'*') then do;
    call execute('footnote h=11pt justify=left font=Calibri color=black bold "* Multiple clinics are reported here";');
    stop;
  end;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 28 Apr 2021 16:05:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-export-to-excel-a-0-observation-data-with-a-quot-No-Data/m-p/737630#M229986</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2021-04-28T16:05:52Z</dc:date>
    </item>
    <item>
      <title>Re: How to export to excel a 0 observation data with a "No Data" note.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-export-to-excel-a-0-observation-data-with-a-quot-No-Data/m-p/737635#M229988</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159"&gt;@Tom&lt;/a&gt;&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/226565"&gt;@japelin&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;below is the full code that I have that works so far, except the issue I have now.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If the dataset has&amp;nbsp; 0 observations (see "dataset = datanew" in the code below)&amp;nbsp;then it will not export any excel sheet. I should have noted that I am running two serpate proc reports and exporting the restuls in one excel with two sheets. So one dataset will always have some data (see data&amp;nbsp;= data_cum)&amp;nbsp;and it will export to the excel sheet, but the other dataset (datanew)&amp;nbsp;sometimes may have data to export and other times will have 0 observations,&amp;nbsp;at which&amp;nbsp;point&amp;nbsp;there will be no excel&amp;nbsp;sheet produced at all,&amp;nbsp;this dataset is created conditional of the day of the reporting. Suggestions? I will try &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/226565"&gt;@japelin&lt;/a&gt;&amp;nbsp;suggestions below i wonder if that will work.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;ods excel file ='C:\report.xlsx' ;
ods escapechar ='^';
ODS excel options(Embedded_Titles ='yes' embedded_footnotes='yes' sheet_name='New Patients');

title1 j=l h=11pt color=black font=Calibri bold 
"^{style[fontweight=bold]
Summary of ^{style[fontstyle=italic] New} Patients County and Clinic}";

title2 j=l h=11pt color=black font=Calibri  
"^{style[fontweight=bold]Date Complete: ^{style[color=blue fontstyle=italic]%sysfunc(date(),worddate18.)}}";

data _null_;
set x.datanew ;
if index(clinic,'*') then do;
call execute 
('footnote h=11pt justify=left font=Calibri color=black bold  "* Multiple clinics are reported here";');
stop;
end;
run;

 proc report data=x.datanew
 style(header)=[background=darkmagenta color=white font_face='Calibri' fontsize=11pt fontweight=bold]
 style(column)={font_face='Calibri' fontsize=11pt};
  column County clinic New_patients;
  define County / group;
  define clinic  / group;
  define New_patients/ sum;

  rbreak after / summarize style=Header;

  Compute after;
  clinic   ='GRAND TOTAL';
  endcomp;

 run;

ODS excel options (Embedded_Titles ='yes' embedded_footnotes='yes' sheet_name='Existing patients');
title1 j=left color=black font='Calibri' bold
"Summary of Exisiting patients by clinic";
title2 j=l h=11pt color=black font=Calibri  
"^{style[fontweight=bold]Date Complete: ^{style[color=blue fontstyle=italic]%sysfunc(date(),worddate18.)}}";

data _null_;
set x.data_cum ;
if index(clinic,'*') then do;
call execute 
('footnote h=11pt justify=left font=Calibri color=black bold  "* Multiple clinic are reported here";');
stop;
end;
run;

proc report data=x.data_cum
 style(header)=[background=darkmagenta color=white font_face='Calibri' fontsize=11pt fontweight=bold]
 style(column)={font_face='Calibri' fontsize=11pt};
  column clinic cum_pt ;
  define clinic / group;
  define cum_pt / sum;

  rbreak after / summarize style=Header;

  Compute after;
  clinic  ='GRAND TOTAL';
  endcomp;
 run;
ods excel close;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 28 Apr 2021 16:32:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-export-to-excel-a-0-observation-data-with-a-quot-No-Data/m-p/737635#M229988</guid>
      <dc:creator>sas_student1</dc:creator>
      <dc:date>2021-04-28T16:32:59Z</dc:date>
    </item>
    <item>
      <title>Re: How to export to excel a 0 observation data with a "No Data" note.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-export-to-excel-a-0-observation-data-with-a-quot-No-Data/m-p/737759#M230026</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159"&gt;@Tom&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Tried the below code it didn't work &lt;span class="lia-unicode-emoji" title=":disappointed_face:"&gt;😞&lt;/span&gt;&lt;/P&gt;&lt;P&gt;I did post the full code that I was using.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;</description>
      <pubDate>Wed, 28 Apr 2021 23:04:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-export-to-excel-a-0-observation-data-with-a-quot-No-Data/m-p/737759#M230026</guid>
      <dc:creator>sas_student1</dc:creator>
      <dc:date>2021-04-28T23:04:30Z</dc:date>
    </item>
    <item>
      <title>Re: How to export to excel a 0 observation data with a "No Data" note.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-export-to-excel-a-0-observation-data-with-a-quot-No-Data/m-p/737760#M230027</link>
      <description>&lt;P&gt;Did you try the code using the NOBS= option to allow you to check if the source dataset is empty?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Make sure to test for zero observations BEFORE the SET statement.&amp;nbsp; Because if wait until after the SET statement then it will be too late and the test will never execute.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Most SAS data steps end when they read past the input in a SET or INPUT statement.&amp;nbsp; Not at the last line of code in the data step.&lt;/P&gt;</description>
      <pubDate>Wed, 28 Apr 2021 23:20:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-export-to-excel-a-0-observation-data-with-a-quot-No-Data/m-p/737760#M230027</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2021-04-28T23:20:23Z</dc:date>
    </item>
    <item>
      <title>Re: How to export to excel a 0 observation data with a "No Data" note.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-export-to-excel-a-0-observation-data-with-a-quot-No-Data/m-p/737762#M230029</link>
      <description>&lt;P&gt;Thank you&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/15475"&gt;@andreas_lds&lt;/a&gt;&amp;nbsp;for the suggestion, unfortunately it didn't work &lt;span class="lia-unicode-emoji" title=":disappointed_face:"&gt;😞&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 28 Apr 2021 23:10:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-export-to-excel-a-0-observation-data-with-a-quot-No-Data/m-p/737762#M230029</guid>
      <dc:creator>sas_student1</dc:creator>
      <dc:date>2021-04-28T23:10:56Z</dc:date>
    </item>
    <item>
      <title>Re: How to export to excel a 0 observation data with a "No Data" note.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-export-to-excel-a-0-observation-data-with-a-quot-No-Data/m-p/737763#M230030</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159"&gt;@Tom&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Below is my full code, where I added the nobs=0 suggestion.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I did before the set statement as per the code.&lt;/P&gt;&lt;P&gt;Not sure what I am doing incorrectly.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;ods excel file ='C:\Report.xlsx' ;
ods escapechar ='^';
ODS excel options(Embedded_Titles ='yes' embedded_footnotes='yes' sheet_name='New Patient');

title1 j=l h=11pt color=black font=Calibri bold 
"^{style[fontweight=bold]
Summary of ^{style[fontstyle=italic] New} Patient by County and Clinic}";

title2 j=l h=11pt color=black font=Calibri  
"^{style[fontweight=bold]Date Complete: ^{style[color=blue fontstyle=italic]%sysfunc(date(),worddate18.)}}";

data _null_;
if nobs=0 then call execute('footnote h=11pt justify=left font=Calibri color=black bold "No data available.";');
set zero_obs nobs=nobs;
if index(clinic,'*') then do;
call execute 
('footnote h=11pt justify=left font=Calibri color=black bold  "* Multiple clinics are reported here";');
stop;
end;
run;

 proc report data=zero_obs 
 style(header)=[background=darkmagenta color=white font_face='Calibri' fontsize=11pt fontweight=bold]
 style(column)={font_face='Calibri' fontsize=11pt};
  column County Clinic new_pat ;
  define County / group;
  define Clinic / group;
  define new_pat / sum;

rbreak after / summarize style=Header;

  Compute after;
  Clinic ='GRAND TOTAL';
  endcomp;

 run;

ODS excel options (Embedded_Titles ='yes' embedded_footnotes='yes' sheet_name='Existing patients');
title1 j=left color=black font='Calibri' bold
"Summary of Existing pateints by clinic";
title2 j=l h=11pt color=black font=Calibri  
"^{style[fontweight=bold]Date Complete: ^{style[color=blue fontstyle=italic]%sysfunc(date(),worddate18.)}}";

data _null_;
set existing_pt ;
if index(program_name,'*') then do;
call execute 
('footnote h=11pt justify=left font=Calibri color=black bold  "* Multiple programs are reported here";');
stop;
end;
run;

proc report data=existing_pt 
 style(header)=[background=darkmagenta color=white font_face='Calibri' fontsize=11pt fontweight=bold]
 style(column)={font_face='Calibri' fontsize=11pt};
  column clinic existing_pt;
  define clinic / group;
  define existing_pt / sum;

  rbreak after / summarize style=Header;

  Compute after;
  clinic ='GRAND TOTAL';
  endcomp;
 run;

ods excel close;
title1 "";&lt;/PRE&gt;</description>
      <pubDate>Wed, 28 Apr 2021 23:20:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-export-to-excel-a-0-observation-data-with-a-quot-No-Data/m-p/737763#M230030</guid>
      <dc:creator>sas_student1</dc:creator>
      <dc:date>2021-04-28T23:20:34Z</dc:date>
    </item>
    <item>
      <title>Re: How to export to excel a 0 observation data with a "No Data" note.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-export-to-excel-a-0-observation-data-with-a-quot-No-Data/m-p/737766#M230033</link>
      <description>&lt;P&gt;Since you are using PROC REPORT you cannot depend on it generating ANY output.&lt;/P&gt;
&lt;P&gt;Try this test:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc report data=sashelp.class(obs=0);
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;If you used PROC EXPORT to write the sheet then it would run even if the dataset is empty.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So in that case you need to use something other than the FOOTNOTE to tell the users there is no data.&lt;/P&gt;
&lt;P&gt;You could use FILE PRINT.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data class1 class2;
  set sashelp.class(obs=5);
  output class2 ;
run;

ods excel file='c:\downloads\empty.xlsx';
ods excel options (sheet_name='CLASS1');

data _null_;
  if nobs=0 then do;
     file print titles;
     put // 'There is no data';
  end;
  set class1 nobs=nobs;
run;

proc print data=sashelp.class1;
run;

ods excel options (sheet_name='CLASS2');

data _null_;
  if nobs=0 then do;
     file print titles;
     put // 'There is no data';
  end;
  set class2 nobs=nobs;
run;

proc print data=class2;
run;

ods excel close;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Or you could add an empty observation to the dataset you are planning to pass to PROC REPORT. (Remember to remove the STOP statement and add an explicit OUTPUT to copy the data when it is present.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data zero_obs_report;
  if nobs=0 then do;
     call execute('footnote h=11pt justify=left font=Calibri color=black bold "No data available.";');
     output;
  end;
  set zero_obs nobs=nobs;
  if index(clinic,'*') then do;
    call execute 
      ('footnote h=11pt justify=left font=Calibri color=black bold  "* Multiple clinics are reported here";')
    ;
  end;
  output;
run;

proc report data=zero_obs_report  ....&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 28 Apr 2021 23:38:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-export-to-excel-a-0-observation-data-with-a-quot-No-Data/m-p/737766#M230033</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2021-04-28T23:38:00Z</dc:date>
    </item>
    <item>
      <title>Re: How to export to excel a 0 observation data with a "No Data" note.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-export-to-excel-a-0-observation-data-with-a-quot-No-Data/m-p/737776#M230037</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159"&gt;@Tom&lt;/a&gt;&amp;nbsp; YOU ARE A GENIUS!!!!!!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;All your suggestions were great but the last option worked!!!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;You ROCK!! YOU ALL ROCK!!!!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;THANK YOU!&lt;/P&gt;</description>
      <pubDate>Thu, 29 Apr 2021 00:42:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-export-to-excel-a-0-observation-data-with-a-quot-No-Data/m-p/737776#M230037</guid>
      <dc:creator>sas_student1</dc:creator>
      <dc:date>2021-04-29T00:42:52Z</dc:date>
    </item>
  </channel>
</rss>

