<?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: &amp;quot;The workbook cannot be opened or repaired by Microsoft Excel because it is corrupt&amp;quot; in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/quot-The-workbook-cannot-be-opened-or-repaired-by-Microsoft/m-p/777736#M247479</link>
    <description>&lt;P&gt;Well now that's interesting. Could you tell me how I would write a line(s) to the Excel file? I had no idea PUT only worked for the log.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;There is an entire section above that code that will generate output for the same named file (if there is any that is). This section is only used if no output records exist. Could I use PROC EXPORT and write lines to the file?&lt;/P&gt;</description>
    <pubDate>Mon, 01 Nov 2021 18:12:53 GMT</pubDate>
    <dc:creator>Jeff_DOC</dc:creator>
    <dc:date>2021-11-01T18:12:53Z</dc:date>
    <item>
      <title>"The workbook cannot be opened or repaired by Microsoft Excel because it is corrupt"</title>
      <link>https://communities.sas.com/t5/SAS-Programming/quot-The-workbook-cannot-be-opened-or-repaired-by-Microsoft/m-p/777721#M247470</link>
      <description>&lt;P&gt;Good morning.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have code that run and periodically generates no qualifying records. When this happens I'd like the user to receive a report with the same name but with just two lines stating no qualifying records exist for this reporting period.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have no idea what I'm doing wrong here.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks very much.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%END;&lt;BR /&gt;%ELSE %DO;&lt;BR /&gt;data _null_;&lt;BR /&gt;ods Excel file= "\\LOCATION\sasdata\Users\USERNAME\OCMS_No_PSC_&amp;amp;SYSDATE..xlsx";&lt;BR /&gt;put "No qualifying records were found for the report period";&lt;BR /&gt;put "SECTION NAME";&lt;BR /&gt;run;&lt;BR /&gt;%END;&lt;/P&gt;</description>
      <pubDate>Mon, 01 Nov 2021 16:48:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/quot-The-workbook-cannot-be-opened-or-repaired-by-Microsoft/m-p/777721#M247470</guid>
      <dc:creator>Jeff_DOC</dc:creator>
      <dc:date>2021-11-01T16:48:51Z</dc:date>
    </item>
    <item>
      <title>Re: "The workbook cannot be opened or repaired by Microsoft Excel because it is corrupt"</title>
      <link>https://communities.sas.com/t5/SAS-Programming/quot-The-workbook-cannot-be-opened-or-repaired-by-Microsoft/m-p/777735#M247478</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/3264"&gt;@Jeff_DOC&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Good morning.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have code that run and periodically generates no qualifying records. When this happens I'd like the user to receive a report with the same name but with just two lines stating no qualifying records exist for this reporting period.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have no idea what I'm doing wrong here.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks very much.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%END;&lt;BR /&gt;%ELSE %DO;&lt;BR /&gt;data _null_;&lt;BR /&gt;ods Excel file= "\\LOCATION\sasdata\Users\USERNAME\OCMS_No_PSC_&amp;amp;SYSDATE..xlsx";&lt;BR /&gt;put "No qualifying records were found for the report period";&lt;BR /&gt;put "SECTION NAME";&lt;BR /&gt;run;&lt;BR /&gt;%END;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Your posted code does not create any ODS output. So without any content your may have an issue. PUT writes to the log. You need more work to write to a file.&lt;/P&gt;
&lt;P&gt;Missing an "Ods Excel Close;" statement likely but can't tell with partial code. Missing close means SAS is still attempting to use the file and opening in Excel will have issues.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 01 Nov 2021 18:06:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/quot-The-workbook-cannot-be-opened-or-repaired-by-Microsoft/m-p/777735#M247478</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2021-11-01T18:06:03Z</dc:date>
    </item>
    <item>
      <title>Re: "The workbook cannot be opened or repaired by Microsoft Excel because it is corrupt"</title>
      <link>https://communities.sas.com/t5/SAS-Programming/quot-The-workbook-cannot-be-opened-or-repaired-by-Microsoft/m-p/777736#M247479</link>
      <description>&lt;P&gt;Well now that's interesting. Could you tell me how I would write a line(s) to the Excel file? I had no idea PUT only worked for the log.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;There is an entire section above that code that will generate output for the same named file (if there is any that is). This section is only used if no output records exist. Could I use PROC EXPORT and write lines to the file?&lt;/P&gt;</description>
      <pubDate>Mon, 01 Nov 2021 18:12:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/quot-The-workbook-cannot-be-opened-or-repaired-by-Microsoft/m-p/777736#M247479</guid>
      <dc:creator>Jeff_DOC</dc:creator>
      <dc:date>2021-11-01T18:12:53Z</dc:date>
    </item>
    <item>
      <title>Re: "The workbook cannot be opened or repaired by Microsoft Excel because it is corrupt"</title>
      <link>https://communities.sas.com/t5/SAS-Programming/quot-The-workbook-cannot-be-opened-or-repaired-by-Microsoft/m-p/777738#M247480</link>
      <description>&lt;P&gt;You can use PUT to write to other places than the LOG.&amp;nbsp; But you need execute a FILE statement first.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%IF .... %THEN %DO;
....
%END;
%ELSE %DO;
ods excel file= "\\LOCATION\sasdata\Users\USERNAME\OCMS_No_PSC_&amp;amp;SYSDATE..xlsx";
data _null_;
  file print;
  put "No qualifying records were found for the report period";
  put "SECTION NAME";
run;
ods excel close;
%END;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 01 Nov 2021 18:32:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/quot-The-workbook-cannot-be-opened-or-repaired-by-Microsoft/m-p/777738#M247480</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2021-11-01T18:32:48Z</dc:date>
    </item>
    <item>
      <title>Re: "The workbook cannot be opened or repaired by Microsoft Excel because it is corrupt"</title>
      <link>https://communities.sas.com/t5/SAS-Programming/quot-The-workbook-cannot-be-opened-or-repaired-by-Microsoft/m-p/777739#M247481</link>
      <description>&lt;P&gt;Worked like a charm (after correcting all my typos). Thanks very much.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 01 Nov 2021 18:40:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/quot-The-workbook-cannot-be-opened-or-repaired-by-Microsoft/m-p/777739#M247481</guid>
      <dc:creator>Jeff_DOC</dc:creator>
      <dc:date>2021-11-01T18:40:03Z</dc:date>
    </item>
    <item>
      <title>Re: "The workbook cannot be opened or repaired by Microsoft Excel because it is corrupt"</title>
      <link>https://communities.sas.com/t5/SAS-Programming/quot-The-workbook-cannot-be-opened-or-repaired-by-Microsoft/m-p/777747#M247488</link>
      <description>Or save the data to a data set and use PROC REPORT with the NOHEADER option to export.</description>
      <pubDate>Mon, 01 Nov 2021 19:05:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/quot-The-workbook-cannot-be-opened-or-repaired-by-Microsoft/m-p/777747#M247488</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2021-11-01T19:05:40Z</dc:date>
    </item>
    <item>
      <title>Re: "The workbook cannot be opened or repaired by Microsoft Excel because it is corrupt"</title>
      <link>https://communities.sas.com/t5/SAS-Programming/quot-The-workbook-cannot-be-opened-or-repaired-by-Microsoft/m-p/777753#M247492</link>
      <description>&lt;P&gt;Another great idea. Thank you Reeza. I will keep both in mind.&lt;/P&gt;</description>
      <pubDate>Mon, 01 Nov 2021 19:15:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/quot-The-workbook-cannot-be-opened-or-repaired-by-Microsoft/m-p/777753#M247492</guid>
      <dc:creator>Jeff_DOC</dc:creator>
      <dc:date>2021-11-01T19:15:58Z</dc:date>
    </item>
  </channel>
</rss>

