<?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: export large datasets to .xlsm file in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/export-large-datasets-to-xlsm-file/m-p/294343#M61406</link>
    <description>&lt;P&gt;It's your SAS version that matters not EG.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can use the following to find your version, it will display in the log. &amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%put &amp;amp;sysver;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;if if you're on SAS 9.2 you may have issues.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;SAS 9.3 should have options. Worse case scenario look up a macro called rich/poor proc expert that will allow you export your data.&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 26 Aug 2016 10:39:37 GMT</pubDate>
    <dc:creator>Reeza</dc:creator>
    <dc:date>2016-08-26T10:39:37Z</dc:date>
    <item>
      <title>export large datasets to .xlsm file</title>
      <link>https://communities.sas.com/t5/SAS-Programming/export-large-datasets-to-xlsm-file/m-p/294316#M61394</link>
      <description>&lt;P&gt;Dear Sas folks,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I try to export a large table (40k records comparable to sashelp.snacks) to an existing&amp;nbsp;.xlsm file (microsoft excel macro file). But i dont's succeed &lt;span class="lia-unicode-emoji" title=":disappointed_face:"&gt;😞&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Does anyone have the golden tip?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;i tried an failed with the following methods:&lt;/P&gt;&lt;P&gt;1) use proc export with dbms=xlsx. SAS creates a xlsx file even if the outfile is defined als xlsm.&lt;/P&gt;&lt;P&gt;2) use proc export with dbms=xlsm i get the message&amp;nbsp; errror: DBMS type XLSM not valid for export.&lt;/P&gt;&lt;P&gt;3)&amp;nbsp;assign a libname with the pc engine to the macro file and&amp;nbsp; use ods excel and proc print&lt;/P&gt;&lt;P&gt;4) assign a libname with the pc engine to the macro file and use a range in the xlsm file. then use proc copy. success with small files, no succes with large files.&lt;/P&gt;&lt;P&gt;5)&amp;nbsp; assign a libname with the pc engine to the macro file and then use a data stap&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;i use sas EG 6.1. and SAS version 9.4.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Kind regards,&lt;/P&gt;&lt;P&gt;Unito&lt;/P&gt;</description>
      <pubDate>Fri, 26 Aug 2016 13:45:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/export-large-datasets-to-xlsm-file/m-p/294316#M61394</guid>
      <dc:creator>Unito</dc:creator>
      <dc:date>2016-08-26T13:45:22Z</dc:date>
    </item>
    <item>
      <title>Re: export large datasets to .xlsm file</title>
      <link>https://communities.sas.com/t5/SAS-Programming/export-large-datasets-to-xlsm-file/m-p/294319#M61395</link>
      <description>&lt;P&gt;SAS does not interact with XLSM. &amp;nbsp;From what I remember XLSM files contain binary components for the VBA to work, hence they are not really open source.&lt;/P&gt;
&lt;P&gt;If you are happy using Excel and VBA, then the simplest way to acheive what you want is to export the data from SAS to CSV, then in your XLSM write a small bit of VBA code (doesn't actually have to stay in the code, you could do it in a separate XLSM), which opens the CSV, and processes the data into your XLSM file.&lt;/P&gt;
&lt;P&gt;Pretty simple, create an Excel. &amp;nbsp;Create an onpen VBA which opens the XLSM file, then opens the CSV file, then copies the data from A2:xlEnd &amp;nbsp;to your XLSM where you want to put it.&lt;/P&gt;</description>
      <pubDate>Fri, 26 Aug 2016 09:40:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/export-large-datasets-to-xlsm-file/m-p/294319#M61395</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2016-08-26T09:40:54Z</dc:date>
    </item>
    <item>
      <title>Re: export large datasets to .xlsm file</title>
      <link>https://communities.sas.com/t5/SAS-Programming/export-large-datasets-to-xlsm-file/m-p/294325#M61397</link>
      <description>&lt;P&gt;To extend &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/45151"&gt;@RW9﻿&lt;/a&gt;: Using .xlsm instead of just .xlsx suggests additional logic is kept there. Frankly, I would never use Excel for more than data display, and in fact I don't even do that. Keep the logic in SAS, where it is much easier to document and keep a version history of SAS codes.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 26 Aug 2016 09:59:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/export-large-datasets-to-xlsm-file/m-p/294325#M61397</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2016-08-26T09:59:00Z</dc:date>
    </item>
    <item>
      <title>Re: export large datasets to .xlsm file</title>
      <link>https://communities.sas.com/t5/SAS-Programming/export-large-datasets-to-xlsm-file/m-p/294343#M61406</link>
      <description>&lt;P&gt;It's your SAS version that matters not EG.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can use the following to find your version, it will display in the log. &amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%put &amp;amp;sysver;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;if if you're on SAS 9.2 you may have issues.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;SAS 9.3 should have options. Worse case scenario look up a macro called rich/poor proc expert that will allow you export your data.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 26 Aug 2016 10:39:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/export-large-datasets-to-xlsm-file/m-p/294343#M61406</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2016-08-26T10:39:37Z</dc:date>
    </item>
    <item>
      <title>Re: export large datasets to .xlsm file</title>
      <link>https://communities.sas.com/t5/SAS-Programming/export-large-datasets-to-xlsm-file/m-p/294386#M61418</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;SAS Forum: export large datasets to .xlsm

Cross posted from SAS-L
You can find a lot of information on dealing with foreign files on SAS-L

http://goo.gl/9OzDmv
https://communities.sas.com/t5/Base-SAS-Programming/export-large-datasets-to-xlsm-file/m-p/294316

HAVE (XLSM formatted Excel file)

1
2
3


SHEET1

WANT (Append 4)

HAVE (XLSM formatted Excel file)

1
2
3
4

SHEET1

SOLUTION

* It might be better to write to another xlsm workbook or
  to write to a temp XLSM and rename it. Unless your code is rock solid
  it is easy to corrupt your original XLSM;

%utl_submit_py64(%nrbquote(
from openpyxl import Workbook;
from openpyxl import load_workbook;
wb = load_workbook(filename='d:/xls/utl_xlsm_sample.xlsm', read_only=False, keep_vba=True);
/* grab the active worksheet */
ws = wb.active;

/* Data can be assigned directly to cells */
ws['A4'] = 88;

wb.save('d:/xls/utl_xlsm_sample.xlsm');
));

SAS MACRO


%macro utl_submit_py64(pgm)/des="Semi colon separated set of py commands";
  * write the program to a temporary file;
  filename py_pgm "%sysfunc(pathname(work))/py_pgm.py" lrecl=32766 recfm=v;
  data _null_;
    length pgm  $32755 cmd $255;
    file py_pgm ;
    pgm="&amp;amp;pgm";
    semi=countc(pgm,';');
      do idx=1 to semi;
        cmd=cats(scan(pgm,idx,';'));
        if cmd=:'.' then cmd=substr(cmd,2);
        put cmd $char96.;
        putlog cmd $char96.;
      end;
  run;
  %let _loc=%sysfunc(pathname(py_pgm));
  %put &amp;amp;_loc;
  filename rut pipe  "C:\Python_27_64bit/python.exe &amp;amp;_loc";
  data _null_;
    file print;
    infile rut;
    input;
    put _infile_;
  run;
  filename rut clear;
  filename py_pgm clear;
%mend utl_submit_py64;


&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 26 Aug 2016 13:48:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/export-large-datasets-to-xlsm-file/m-p/294386#M61418</guid>
      <dc:creator>rogerjdeangelis</dc:creator>
      <dc:date>2016-08-26T13:48:04Z</dc:date>
    </item>
    <item>
      <title>Re: export large datasets to .xlsm file</title>
      <link>https://communities.sas.com/t5/SAS-Programming/export-large-datasets-to-xlsm-file/m-p/347351#M80207</link>
      <description>&lt;P&gt;this will work :&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;%sysexec( copy "Path\workbookname.xlsm"&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; "Path\workbookname.xlsx" ) ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Proc export data = your_data outfile = "Path\workbookname.xlsx" &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Dbms = Xlsx replace ;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;run ;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;%sysexec( copy "Path\workbookname.xlsx"&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; "Path\workbookname.xlsm" ) ;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 05 Apr 2017 13:31:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/export-large-datasets-to-xlsm-file/m-p/347351#M80207</guid>
      <dc:creator>Mokben</dc:creator>
      <dc:date>2017-04-05T13:31:55Z</dc:date>
    </item>
  </channel>
</rss>

