<?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: Removing the .bak with proc export in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Removing-the-bak-with-proc-export/m-p/787251#M251516</link>
    <description>&lt;P&gt;The code you posted does not include any call to the macro.&amp;nbsp; So you never asked it to delete the .bak file.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro xlsx_bak_delete(file) / des='Delete backup spreadsheets';
option mprint notes;
data _null_;
fname = 'todelete';
rc = filename(fname, "&amp;amp;file..xlsx.bak");
rc = fdelete(fname);
rc = filename(fname);
run;
%mend xlsx_bak_delete;
%xlsx_bak_delete(file=&amp;amp;glb_path2./reports/mth_ak/zab_polisy&amp;amp;gv_tbl_date)&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Thu, 23 Dec 2021 16:20:23 GMT</pubDate>
    <dc:creator>Tom</dc:creator>
    <dc:date>2021-12-23T16:20:23Z</dc:date>
    <item>
      <title>Removing the .bak with proc export</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Removing-the-bak-with-proc-export/m-p/787216#M251490</link>
      <description>&lt;P&gt;I have a problem because when exporting with proc export a few excels creates an additional file with the abbreviation .bak. I searched the form and found such a macro, but it does not work for me. Maybe I am doing something wrong, or is there any possibility to change the settings that did not back up with proc export&lt;/P&gt;
&lt;PRE&gt;proc export data=DIFF_FINAL
            outfile="&amp;amp;glb_path2./reports/mth_ak/zab_polisy&amp;amp;gv_tbl_date..xlsx"
            dbms=xlsx
            replace;
            sheet="Roznice";
run; 

%macro xlsx_bak_delete(file=&amp;amp;glb_path2./reports/mth_ak/zab_polisy&amp;amp;gv_tbl_date) / des='Delete backup spreadsheets';
option mprint notes;
data _null_;
fname = 'todelete';
rc = filename(fname, "&amp;amp;file..xlsx.bak");
rc = fdelete(fname);
rc = filename(fname);
run;
%mend xlsx_bak_delete;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Gieorgie_0-1640254260177.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/66940i988756DED7D42FB9/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Gieorgie_0-1640254260177.png" alt="Gieorgie_0-1640254260177.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 23 Dec 2021 10:11:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Removing-the-bak-with-proc-export/m-p/787216#M251490</guid>
      <dc:creator>Gieorgie</dc:creator>
      <dc:date>2021-12-23T10:11:14Z</dc:date>
    </item>
    <item>
      <title>Re: Removing the .bak with proc export</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Removing-the-bak-with-proc-export/m-p/787219#M251493</link>
      <description>&lt;P&gt;This is a bit outside my usual work/knowledge in SAS, but I have a couple questions.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;1. Have you considered using the XLSX engine in the LIBNAME statement instead of PROC EXPORT? &lt;A href="https://blogs.sas.com/content/sasdummy/2015/05/20/using-libname-xlsx-to-read-and-write-excel-files/" target="_self"&gt;(link)&lt;/A&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;2. Can you show us your log with the messages? The macro turns uses MPRINT, and seeing what's going on would help. You might even want to turn on SYMBOLGEN to see if your macro variables are resolving correctly.&lt;/P&gt;
&lt;P&gt;3. Are you having to delete multiple .bak files? If not, There may not be a need for a macro.&lt;/P&gt;
&lt;P&gt;4. It seems as though you got the macro from the following link. Did you see the comment that someone uses the EXCEL engine and doesn't have any issues? I'm taking their word for it, but I don't typically use Excel files. &lt;A href="https://communities.sas.com/t5/SAS-Programming/Clean-bak-files-from-PROC-EXPORT/td-p/316201" target="_self"&gt;(link)&lt;/A&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Also, note that in the blog post in (1) that the XLSX engine directly accesses the excel file, whereas the EXCEL engine relies on Microsoft API's.&lt;/P&gt;</description>
      <pubDate>Thu, 23 Dec 2021 10:59:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Removing-the-bak-with-proc-export/m-p/787219#M251493</guid>
      <dc:creator>maguiremq</dc:creator>
      <dc:date>2021-12-23T10:59:14Z</dc:date>
    </item>
    <item>
      <title>Re: Removing the .bak with proc export</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Removing-the-bak-with-proc-export/m-p/787224#M251495</link>
      <description>&lt;P&gt;Hi its resolved now :&lt;/P&gt;
&lt;PRE&gt;data _null_;
	fname = "todelete";
	rc = filename(fname, "&amp;amp;glb_path2./reports/mth_ak/zab_polisy&amp;amp;gv_tbl_date..xlsx.bak");
	if rc = 0 and fexist(fname) then rc=fdelete(fname);
	rc = filename(fname);
run;&lt;/PRE&gt;</description>
      <pubDate>Thu, 23 Dec 2021 11:05:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Removing-the-bak-with-proc-export/m-p/787224#M251495</guid>
      <dc:creator>Gieorgie</dc:creator>
      <dc:date>2021-12-23T11:05:16Z</dc:date>
    </item>
    <item>
      <title>Re: Removing the .bak with proc export</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Removing-the-bak-with-proc-export/m-p/787225#M251496</link>
      <description>&lt;P&gt;We would need to see how you call the macro (if you did not call it, then nothing would happen anyway).&lt;/P&gt;</description>
      <pubDate>Thu, 23 Dec 2021 11:13:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Removing-the-bak-with-proc-export/m-p/787225#M251496</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2021-12-23T11:13:32Z</dc:date>
    </item>
    <item>
      <title>Re: Removing the .bak with proc export</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Removing-the-bak-with-proc-export/m-p/787251#M251516</link>
      <description>&lt;P&gt;The code you posted does not include any call to the macro.&amp;nbsp; So you never asked it to delete the .bak file.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro xlsx_bak_delete(file) / des='Delete backup spreadsheets';
option mprint notes;
data _null_;
fname = 'todelete';
rc = filename(fname, "&amp;amp;file..xlsx.bak");
rc = fdelete(fname);
rc = filename(fname);
run;
%mend xlsx_bak_delete;
%xlsx_bak_delete(file=&amp;amp;glb_path2./reports/mth_ak/zab_polisy&amp;amp;gv_tbl_date)&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 23 Dec 2021 16:20:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Removing-the-bak-with-proc-export/m-p/787251#M251516</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2021-12-23T16:20:23Z</dc:date>
    </item>
    <item>
      <title>Re: Removing the .bak with proc export</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Removing-the-bak-with-proc-export/m-p/847464#M335054</link>
      <description>If you run SAS on Linux environment you can call Linux commands.&lt;BR /&gt;Just add this to the end of the code.&lt;BR /&gt;x cd /path_to_folder;&lt;BR /&gt; x rm *.xlsx.bak;</description>
      <pubDate>Fri, 02 Dec 2022 16:13:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Removing-the-bak-with-proc-export/m-p/847464#M335054</guid>
      <dc:creator>klchtsk</dc:creator>
      <dc:date>2022-12-02T16:13:07Z</dc:date>
    </item>
    <item>
      <title>Re: Removing the .bak with proc export</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Removing-the-bak-with-proc-export/m-p/870084#M343678</link>
      <description>It's working for me! Thanks for this code</description>
      <pubDate>Mon, 17 Apr 2023 04:21:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Removing-the-bak-with-proc-export/m-p/870084#M343678</guid>
      <dc:creator>tinton</dc:creator>
      <dc:date>2023-04-17T04:21:56Z</dc:date>
    </item>
  </channel>
</rss>

