<?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: SAS to Excel export: file corrupted one run, works the next in SAS Data Management</title>
    <link>https://communities.sas.com/t5/SAS-Data-Management/SAS-to-Excel-export-file-corrupted-one-run-works-the-next/m-p/397962#M12084</link>
    <description>&lt;P&gt;Correction to the above - I did get the sleep to work by adding the units: call sleep(10,1). However the Excel issue is still persisting.&lt;/P&gt;</description>
    <pubDate>Thu, 21 Sep 2017 23:38:06 GMT</pubDate>
    <dc:creator>adkilmer</dc:creator>
    <dc:date>2017-09-21T23:38:06Z</dc:date>
    <item>
      <title>SAS to Excel export: file corrupted one run, works the next</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/SAS-to-Excel-export-file-corrupted-one-run-works-the-next/m-p/397899#M12075</link>
      <description>&lt;P&gt;I am running a program that pulls together several data sets. At the end of the macro, the data is all exported to named ranges in an Excel file, and the ranges populate several tables on different worksheets.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For the past few days, every time I run this program, the Excel file will not open. Instead I get the error in the attached screenshot. I get one warning in the SAS log, "No matching members in directory," on a PROC DATASETS statement. It seems like something's going wrong with the creating of the file, not the export.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Even stranger, if I run only the code that creates the Excel file and exports the data, the resulting Excel file populates correctly and can be opened. So what is causing the Excel file to get corrupted?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What follows is an abbreviated version of the code that creates the file and exports the data.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data _null_;&lt;BR /&gt;x "cp ""/sasprod/ca/sasdata/innovation/cost and use/CandU_Executive_Summary_Shell.xlsx""&lt;BR /&gt;""/sasprod/ca/sasdata/innovation/cost and use/Cost_and_Use_Dashboard_&amp;amp;client._&amp;amp;rundate..xlsx"" ";&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;libname rptbase2 pcfiles&lt;BR /&gt;server=DT1&lt;BR /&gt;version=2007&lt;BR /&gt;path="\\grid\sasprod\ca\sasdata\innovation\cost and use\Cost_and_Use_Dashboard_&amp;amp;client._&amp;amp;rundate..xlsx";&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;proc datasets lib=rptbase2;&lt;BR /&gt;delete bands;&lt;BR /&gt;delete age_band;&lt;BR /&gt;delete readmissions;&lt;BR /&gt;quit;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;proc sql;&lt;BR /&gt;create table rptbase2.bands as select * from bands;&lt;BR /&gt;quit;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;proc sql;&lt;BR /&gt;create table rptbase2.readmissions as select * from readmissions;&lt;BR /&gt;quit;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;proc sql;&lt;BR /&gt;create table rptbase2.age_band as select * from age_band;&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Excel corrupted.PNG" style="width: 600px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/15345iCF59D29068BA5CF3/image-size/large?v=v2&amp;amp;px=999" role="button" title="Excel corrupted.PNG" alt="Excel corrupted.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 21 Sep 2017 19:19:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/SAS-to-Excel-export-file-corrupted-one-run-works-the-next/m-p/397899#M12075</guid>
      <dc:creator>adkilmer</dc:creator>
      <dc:date>2017-09-21T19:19:09Z</dc:date>
    </item>
    <item>
      <title>Re: SAS to Excel export: file corrupted one run, works the next</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/SAS-to-Excel-export-file-corrupted-one-run-works-the-next/m-p/397914#M12076</link>
      <description>&lt;P&gt;Can you include the log from this code?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Is there any possibility any of the data goes beyond the named ranges sizes?&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 21 Sep 2017 20:07:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/SAS-to-Excel-export-file-corrupted-one-run-works-the-next/m-p/397914#M12076</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-09-21T20:07:10Z</dc:date>
    </item>
    <item>
      <title>Re: SAS to Excel export: file corrupted one run, works the next</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/SAS-to-Excel-export-file-corrupted-one-run-works-the-next/m-p/397916#M12077</link>
      <description>&lt;P&gt;The log for the relevant part of the program is attached.&lt;/P&gt;</description>
      <pubDate>Thu, 21 Sep 2017 20:11:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/SAS-to-Excel-export-file-corrupted-one-run-works-the-next/m-p/397916#M12077</guid>
      <dc:creator>adkilmer</dc:creator>
      <dc:date>2017-09-21T20:11:13Z</dc:date>
    </item>
    <item>
      <title>Re: SAS to Excel export: file corrupted one run, works the next</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/SAS-to-Excel-export-file-corrupted-one-run-works-the-next/m-p/397918#M12078</link>
      <description>&lt;P&gt;You are really removing sheets from an XLSX file using SAS? &amp;nbsp;Why?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Does the COPY command at the top have anything to do with this? &amp;nbsp;&lt;/P&gt;
&lt;P&gt;Are you sure that you waited for the file to finish copying before trying to modify it?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Are you sure that no one else is trying to read or modify the same file at the same time?&lt;/P&gt;</description>
      <pubDate>Thu, 21 Sep 2017 20:19:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/SAS-to-Excel-export-file-corrupted-one-run-works-the-next/m-p/397918#M12078</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2017-09-21T20:19:54Z</dc:date>
    </item>
    <item>
      <title>Re: SAS to Excel export: file corrupted one run, works the next</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/SAS-to-Excel-export-file-corrupted-one-run-works-the-next/m-p/397945#M12080</link>
      <description>&lt;P&gt;The code is not removing sheets. It is deleting the contents of the named ranges in Excel before loading data to them. I've found that if I skip this step, the program errors out, saying it can't write to the ranges. I have to do this even if there's no data in the range.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;No one else is touching this file. Your comment about the copy finishing is interesting. Is there a way to 'pause' the program for a few seconds after the copy to make sure it finishes before I try to modify the contents?&lt;/P&gt;</description>
      <pubDate>Thu, 21 Sep 2017 21:55:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/SAS-to-Excel-export-file-corrupted-one-run-works-the-next/m-p/397945#M12080</guid>
      <dc:creator>adkilmer</dc:creator>
      <dc:date>2017-09-21T21:55:04Z</dc:date>
    </item>
    <item>
      <title>Re: SAS to Excel export: file corrupted one run, works the next</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/SAS-to-Excel-export-file-corrupted-one-run-works-the-next/m-p/397947#M12081</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/163777"&gt;@adkilmer&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;No one else is touching this file. Your comment about the copy finishing is interesting. Is there a way to 'pause' the program for a few seconds after the copy to make sure it finishes before I try to modify the contents?&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;A data step and CALL SLeep is one way.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Data _null_;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; call sleep(10);&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;has the program wait for 10 seconds.&lt;/P&gt;
&lt;P&gt;this might go immediately after the copy.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 21 Sep 2017 22:26:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/SAS-to-Excel-export-file-corrupted-one-run-works-the-next/m-p/397947#M12081</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2017-09-21T22:26:21Z</dc:date>
    </item>
    <item>
      <title>Re: SAS to Excel export: file corrupted one run, works the next</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/SAS-to-Excel-export-file-corrupted-one-run-works-the-next/m-p/397961#M12083</link>
      <description>&lt;P&gt;I added this exact code, and the program won't 'sleep.' It's blowing right past it like it's not there. The Excel issue is persisting.&lt;/P&gt;</description>
      <pubDate>Thu, 21 Sep 2017 23:29:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/SAS-to-Excel-export-file-corrupted-one-run-works-the-next/m-p/397961#M12083</guid>
      <dc:creator>adkilmer</dc:creator>
      <dc:date>2017-09-21T23:29:50Z</dc:date>
    </item>
    <item>
      <title>Re: SAS to Excel export: file corrupted one run, works the next</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/SAS-to-Excel-export-file-corrupted-one-run-works-the-next/m-p/397962#M12084</link>
      <description>&lt;P&gt;Correction to the above - I did get the sleep to work by adding the units: call sleep(10,1). However the Excel issue is still persisting.&lt;/P&gt;</description>
      <pubDate>Thu, 21 Sep 2017 23:38:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/SAS-to-Excel-export-file-corrupted-one-run-works-the-next/m-p/397962#M12084</guid>
      <dc:creator>adkilmer</dc:creator>
      <dc:date>2017-09-21T23:38:06Z</dc:date>
    </item>
    <item>
      <title>Re: SAS to Excel export: file corrupted one run, works the next</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/SAS-to-Excel-export-file-corrupted-one-run-works-the-next/m-p/400340#M12165</link>
      <description>&lt;P&gt;Hi everyone, I've apparently gotten this to work. I changed the code from:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;data _null_;
    x "cp      ""/sasprod/ca/sasdata/innovation/cost and use/CandU_Executive_Summary_Shell.xlsx"" 
               ""/sasprod/ca/sasdata/innovation/cost and use/Cost_and_Use_Dashboard_&amp;amp;client._&amp;amp;rundate..xlsx"" ";
run;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;To:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;x cp  	"/sasprod/ca/sasdata/innovation/cost and use/CandU_Executive_Summary_Shell.xlsx"
		"/sasprod/ca/sasdata/innovation/cost and use/Cost_and_Use_Dashboard_&amp;amp;client._&amp;amp;rundate..xlsx" ;&lt;/PRE&gt;&lt;P&gt;If anyone could clue me in as to why code #2 works and code #1 doesn't, I'd greatly appreciate it.&lt;/P&gt;</description>
      <pubDate>Mon, 02 Oct 2017 17:20:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/SAS-to-Excel-export-file-corrupted-one-run-works-the-next/m-p/400340#M12165</guid>
      <dc:creator>adkilmer</dc:creator>
      <dc:date>2017-10-02T17:20:02Z</dc:date>
    </item>
    <item>
      <title>Re: SAS to Excel export: file corrupted one run, works the next</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/SAS-to-Excel-export-file-corrupted-one-run-works-the-next/m-p/400344#M12166</link>
      <description>&lt;P&gt;X commands are not supposed to be in a data step.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can use CALL SYSTEM I believe in the data step if you want the X command to work.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;RTM (unix reference but Windows will have the same concept)&lt;/P&gt;
&lt;P&gt;&lt;A href="http://documentation.sas.com/?docsetId=hostunx&amp;amp;docsetTarget=p0w7z1ah45wd1sn1kafn6uibm1mu.htm&amp;amp;docsetVersion=9.4&amp;amp;locale=en" target="_blank"&gt;http://documentation.sas.com/?docsetId=hostunx&amp;amp;docsetTarget=p0w7z1ah45wd1sn1kafn6uibm1mu.htm&amp;amp;docsetVersion=9.4&amp;amp;locale=en&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Neither the X statement nor the %SYSEXEC macro program statement is intended for use during the execution of a DATA step. The CALL SYSTEM routine, however, can be executed within a DATA step.&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN class="xis-xrefSee"&gt;&lt;SPAN class="xis-xrefText"&gt;For an example, see&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;A class="ng-scope" tabindex="0" title="" href="http://documentation.sas.com/?docsetId=hostunx&amp;amp;docsetTarget=n02y32jkcim3izn1ner5rsthh7wb.htm&amp;amp;docsetVersion=9.4&amp;amp;locale=en" rel="nofollow" data-docset-id="hostunx" data-docset-version="9.4" data-original-href="n02y32jkcim3izn1ner5rsthh7wb.htm"&gt;CALL SYSTEM Routine: UNIX&lt;/A&gt;&lt;SPAN class="xis-xrefText"&gt;.&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here's an overview of calling system commands:&lt;/P&gt;
&lt;P&gt;&lt;A href="http://documentation.sas.com/?docsetId=hostunx&amp;amp;docsetTarget=p0w085btd5r0a4n1km4bcdpgqibt.htm&amp;amp;docsetVersion=9.4&amp;amp;locale=en" target="_blank"&gt;http://documentation.sas.com/?docsetId=hostunx&amp;amp;docsetTarget=p0w085btd5r0a4n1km4bcdpgqibt.htm&amp;amp;docsetVersion=9.4&amp;amp;locale=en&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 02 Oct 2017 17:26:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/SAS-to-Excel-export-file-corrupted-one-run-works-the-next/m-p/400344#M12166</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-10-02T17:26:10Z</dc:date>
    </item>
  </channel>
</rss>

