<?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 dataset to xlsx with copy files task in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-export-dataset-to-xlsx-with-copy-files-task/m-p/959546#M374361</link>
    <description>&lt;P&gt;The Copy Files task simply downloads your file from the SAS server file system, whatever its type. So instead of creating a text file, you need to create an XLSX file to download.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can create an XLSX by changing your PROC EXPORT code from DBMS=DLM to DBMS=XLSX. This does require SAS/ACCESS to PC Files to be licensed on the server.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="sas"&gt;%let download_from =
  %sysfunc(getoption(work))&amp;amp;delim.&amp;amp;datafile..xlsx;
 
filename src "&amp;amp;download_from.";
 
proc export data=&amp;amp;lib..&amp;amp;datafile.
	dbms=xlsx 
	file=src
	replace;
run;&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 19 Feb 2025 13:27:26 GMT</pubDate>
    <dc:creator>ChrisHemedinger</dc:creator>
    <dc:date>2025-02-19T13:27:26Z</dc:date>
    <item>
      <title>How to export dataset to xlsx with copy files task</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-export-dataset-to-xlsx-with-copy-files-task/m-p/959537#M374359</link>
      <description>&lt;P&gt;Hello everyone!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So I cannot export a sas dataset using code (no permissions, not really sure why, company policies) but i found out that i can use the task copy files to export a dataset in txt with no problems so basically what i do is:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Create a&amp;nbsp; program:&lt;/P&gt;&lt;PRE&gt;/* Data to export */
%let lib  = WORK;
%let datafile = filename;
%let save_path= mypath

/* Local folder to download to */ 
%let download_to = &amp;amp;save_path;
 
/* detect proper delim for UNIX vs. Windows */
%let delim=%sysfunc(ifc(%eval(&amp;amp;sysscp. = WIN),\,/));
 
%let download_from =
  %sysfunc(getoption(work))&amp;amp;delim.&amp;amp;datafile..txt;
 
filename src "&amp;amp;download_from.";
 
proc export data=&amp;amp;lib..&amp;amp;datafile.
	dbms=dlm 
	file=src
	replace;
	delimiter=';';
run;
 
filename src clear;&lt;/PRE&gt;&lt;P&gt;and then use the copy files like this :&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="msf2021_0-1739906968200.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/104731i1E05C8A372A1681E/image-size/medium?v=v2&amp;amp;px=400" role="button" title="msf2021_0-1739906968200.png" alt="msf2021_0-1739906968200.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want to be able to do the same but now export as xlsx instead of txt&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Can anyone help me please?&lt;/P&gt;</description>
      <pubDate>Tue, 18 Feb 2025 19:29:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-export-dataset-to-xlsx-with-copy-files-task/m-p/959537#M374359</guid>
      <dc:creator>msf2021</dc:creator>
      <dc:date>2025-02-18T19:29:36Z</dc:date>
    </item>
    <item>
      <title>Re: How to export dataset to xlsx with copy files task</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-export-dataset-to-xlsx-with-copy-files-task/m-p/959546#M374361</link>
      <description>&lt;P&gt;The Copy Files task simply downloads your file from the SAS server file system, whatever its type. So instead of creating a text file, you need to create an XLSX file to download.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can create an XLSX by changing your PROC EXPORT code from DBMS=DLM to DBMS=XLSX. This does require SAS/ACCESS to PC Files to be licensed on the server.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="sas"&gt;%let download_from =
  %sysfunc(getoption(work))&amp;amp;delim.&amp;amp;datafile..xlsx;
 
filename src "&amp;amp;download_from.";
 
proc export data=&amp;amp;lib..&amp;amp;datafile.
	dbms=xlsx 
	file=src
	replace;
run;&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 19 Feb 2025 13:27:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-export-dataset-to-xlsx-with-copy-files-task/m-p/959546#M374361</guid>
      <dc:creator>ChrisHemedinger</dc:creator>
      <dc:date>2025-02-19T13:27:26Z</dc:date>
    </item>
    <item>
      <title>Re: How to export dataset to xlsx with copy files task</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-export-dataset-to-xlsx-with-copy-files-task/m-p/959550#M374363</link>
      <description>&lt;P&gt;Delimiter???&amp;nbsp; Why would you use the DELIMITER statement when making an XLSX file?&amp;nbsp; Those do not use delimiters.&lt;/P&gt;</description>
      <pubDate>Tue, 18 Feb 2025 22:12:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-export-dataset-to-xlsx-with-copy-files-task/m-p/959550#M374363</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2025-02-18T22:12:29Z</dc:date>
    </item>
    <item>
      <title>Re: How to export dataset to xlsx with copy files task</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-export-dataset-to-xlsx-with-copy-files-task/m-p/959575#M374371</link>
      <description>&lt;P&gt;Maybe i didn't explain myself clear. The code i posted is to export txt that's why the delimiter. It's an example code because with that code i can export a txt from sas to my computer. What i need is a similar approach to export xlsx&lt;/P&gt;</description>
      <pubDate>Wed, 19 Feb 2025 09:28:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-export-dataset-to-xlsx-with-copy-files-task/m-p/959575#M374371</guid>
      <dc:creator>msf2021</dc:creator>
      <dc:date>2025-02-19T09:28:14Z</dc:date>
    </item>
    <item>
      <title>Re: How to export dataset to xlsx with copy files task</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-export-dataset-to-xlsx-with-copy-files-task/m-p/959579#M374373</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/381594"&gt;@msf2021&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Maybe i didn't explain myself clear. The code i posted is to export txt that's why the delimiter. It's an example code because with that code i can export a txt from sas to my computer. What i need is a similar approach to export xlsx&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/381594"&gt;@msf2021&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The only bit you need to change in your working code is Proc Export so it creates a Excel file instead of a Text file.&amp;nbsp;&lt;BR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/4"&gt;@ChrisHemedinger&lt;/a&gt;&amp;nbsp;already shared the code with you. I assume he copy/pasted your Proc Export code and then modified it for Excel output ...and just missed to remove the delimiter statement.&lt;/P&gt;</description>
      <pubDate>Wed, 19 Feb 2025 10:07:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-export-dataset-to-xlsx-with-copy-files-task/m-p/959579#M374373</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2025-02-19T10:07:14Z</dc:date>
    </item>
    <item>
      <title>Re: How to export dataset to xlsx with copy files task</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-export-dataset-to-xlsx-with-copy-files-task/m-p/959597#M374381</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;
&lt;P&gt;The only bit you need to change in your working code is Proc Export so it creates a Excel file instead of a Text file.&amp;nbsp;&lt;BR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/4"&gt;@ChrisHemedinger&lt;/a&gt;&amp;nbsp;already shared the code with you. I assume he copy/pasted your Proc Export code and then modified it for Excel output ...and just missed to remove the delimiter statement.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Whoops, yes. Fixed that!&lt;/P&gt;</description>
      <pubDate>Wed, 19 Feb 2025 13:28:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-export-dataset-to-xlsx-with-copy-files-task/m-p/959597#M374381</guid>
      <dc:creator>ChrisHemedinger</dc:creator>
      <dc:date>2025-02-19T13:28:07Z</dc:date>
    </item>
    <item>
      <title>Re: How to export dataset to xlsx with copy files task</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-export-dataset-to-xlsx-with-copy-files-task/m-p/959643#M374403</link>
      <description>&lt;P&gt;You explained fine, I was responding to Chris who should know better.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If your existing program + task structure works for text files it should work the same for XLSX files.&amp;nbsp; (Note:&amp;nbsp; If the copy files task as an option to download binary files differently than text file,&amp;nbsp; like FTP does, you need to make sure to copy the files as binary.)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Just make sure to use XLSX as the extension on the filename and use XLSX as the DBMS= option of PROC EXPORT.&amp;nbsp; And of course remove the DELIMITER= statement as it makes no sense for XLSX files.&amp;nbsp; And you can make the program simpler as there is no need to make a fileref to use PROC EXPORT, just specify the filename directly in the FILE= option.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/* Data to export */
%let lib  = WORK;
%let datafile = filename;
%let save_path= mypath

/* Local folder to download to */ 
%let download_to = &amp;amp;save_path;
 
/* detect proper delim for UNIX vs. Windows */
%let delim=%sysfunc(ifc(%eval(&amp;amp;sysscp. = WIN),\,/));
 
%let download_from =
  %sysfunc(getoption(work))&amp;amp;delim.&amp;amp;datafile..xlsx;
 
proc export data=&amp;amp;lib..&amp;amp;datafile.
  dbms=XLSX
  file="&amp;amp;download_from."
  replace
;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 19 Feb 2025 18:14:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-export-dataset-to-xlsx-with-copy-files-task/m-p/959643#M374403</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2025-02-19T18:14:14Z</dc:date>
    </item>
    <item>
      <title>Re: How to export dataset to xlsx with copy files task</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-export-dataset-to-xlsx-with-copy-files-task/m-p/959648#M374405</link>
      <description>&lt;P&gt;How about, instead exporting, use the XLSX libname?&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;libname x XLSX "R:/text.xlsx";

data x.sheet1;
  set sashelp.class;
run;

data x.sheet2;
  set sashelp.cars;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Bart&lt;/P&gt;</description>
      <pubDate>Wed, 19 Feb 2025 18:25:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-export-dataset-to-xlsx-with-copy-files-task/m-p/959648#M374405</guid>
      <dc:creator>yabwon</dc:creator>
      <dc:date>2025-02-19T18:25:30Z</dc:date>
    </item>
    <item>
      <title>Re: How to export dataset to xlsx with copy files task</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-export-dataset-to-xlsx-with-copy-files-task/m-p/959654#M374408</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159"&gt;@Tom&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;If your existing program + task structure works for text files it should work the same for XLSX files.&amp;nbsp; (Note:&amp;nbsp; If the copy files task as an option to download binary files differently than text file,&amp;nbsp; like FTP does, you need to make sure to copy the files as binary.)&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Good point! The Copy Files task has an option to treat as text and fix line-endings (Unix vs Windows). The default is a binary transfer, which saves on encoding hassles. You'll want to check the settings in your task within the project.&lt;/P&gt;</description>
      <pubDate>Wed, 19 Feb 2025 18:43:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-export-dataset-to-xlsx-with-copy-files-task/m-p/959654#M374408</guid>
      <dc:creator>ChrisHemedinger</dc:creator>
      <dc:date>2025-02-19T18:43:29Z</dc:date>
    </item>
  </channel>
</rss>

