<?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: Converting XML to XLSX in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Converting-XML-to-XLSX/m-p/762316#M241345</link>
    <description>&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;The XML file opens fine, I can see all the information as expected.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;If I use ODS EXCEL, the program crashes because the SAS dataset is very big, that is the reason I am creating XML and trying to convert to excel.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;I tried the code you updated, XML created and can be opened fine, the excel file is also generated but has NO information(just blank).&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;What could be the reason?&lt;/DIV&gt;</description>
    <pubDate>Wed, 18 Aug 2021 15:37:33 GMT</pubDate>
    <dc:creator>Semie</dc:creator>
    <dc:date>2021-08-18T15:37:33Z</dc:date>
    <item>
      <title>Converting XML to XLSX</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Converting-XML-to-XLSX/m-p/762120#M241252</link>
      <description>&lt;P&gt;I am trying to convert XML to excel file and got the code from the link below. I created the XML but when I run the code to convert to excel, a corrupted(blank) excel file is created, log looks clean. When I open the file, I got the massage in the screenshot below.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Could anyone help me if I miss any, please?&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Semie_0-1629217333190.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/62669i526BF1719A4EF162/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Semie_0-1629217333190.png" alt="Semie_0-1629217333190.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;A href="https://communities.sas.com/t5/SAS-Procedures/Converting-XML-to-XLSX/td-p/142446" target="_blank"&gt;https://communities.sas.com/t5/SAS-Procedures/Converting-XML-to-XLSX/td-p/142446&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is the code I am using:&amp;nbsp;&lt;/P&gt;&lt;P&gt;ods tagsets.excelxp file="&amp;amp;default\temp.xml" newfile=bygroup;&lt;BR /&gt;proc print data=test;&lt;BR /&gt;run;&lt;BR /&gt;ods tagsets.excelxp close;&lt;/P&gt;&lt;P&gt;%macro convert_files(default=,ext=);&lt;BR /&gt;data _null_;&lt;BR /&gt;file "'&amp;amp;default\temp.xlsx'";&lt;BR /&gt;put "set xlapp = CreateObject(""Excel.Application"")";&lt;BR /&gt;put "set fso = CreateObject(""scripting.filesystemobject"")";&lt;BR /&gt;put "set myfolder = fso.GetFolder(""&amp;amp;default"")";&lt;BR /&gt;put "set myfiles = myfolder.Files";&lt;BR /&gt;put "xlapp.DisplayAlerts = False";&lt;BR /&gt;put " ";&lt;BR /&gt;put "for each f in myfiles";&lt;BR /&gt;put "If f.Size &amp;lt; 70000 And fso.GetExtensionName(f)=""&amp;amp;ext"" Then";&lt;BR /&gt;put " f.Delete True";&lt;BR /&gt;put " End If";&lt;BR /&gt;put " Next";&lt;BR /&gt;put " ";&lt;BR /&gt;put "for each f in myfiles";&lt;BR /&gt;put " ExtName = fso.GetExtensionName(f)";&lt;BR /&gt;put " Filename= fso.GetBaseName(f)";&lt;BR /&gt;put " if ExtName=""&amp;amp;ext"" then";&lt;BR /&gt;put " set mybook = xlapp.Workbooks.Open(f.Path)";&lt;BR /&gt;put " xlapp.Visible = false";&lt;BR /&gt;put " mybook.SaveAs ""&amp;amp;default.\"" &amp;amp; Filename &amp;amp; "".xlsx"", 51";&lt;BR /&gt;put " End If";&lt;BR /&gt;put " Next";&lt;BR /&gt;put " mybook.Close";&lt;BR /&gt;put " xlapp.DisplayAlerts = True";&lt;BR /&gt;/* Removes original files */&lt;BR /&gt;put " FSO.DeleteFile(""&amp;amp;default\*.&amp;amp;ext""), DeleteReadOnly";&lt;BR /&gt;put " xlapp.Quit";&lt;BR /&gt;put " Set xlapp = Nothing";&lt;BR /&gt;put " strScript = Wscript.ScriptFullName";&lt;BR /&gt;put " FSO.DeleteFile(strScript)";&lt;BR /&gt;run;&lt;BR /&gt;&lt;BR /&gt;x "cscript ""&amp;amp;default\temp.xlsx""";&lt;BR /&gt;%mend;&lt;/P&gt;&lt;P&gt;%convert_files(default=H:\CDISC\ADaM\Data\Q2,&lt;BR /&gt;ext=xml);&lt;/P&gt;</description>
      <pubDate>Tue, 17 Aug 2021 16:28:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Converting-XML-to-XLSX/m-p/762120#M241252</guid>
      <dc:creator>Semie</dc:creator>
      <dc:date>2021-08-17T16:28:44Z</dc:date>
    </item>
    <item>
      <title>Re: Converting XML to XLSX</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Converting-XML-to-XLSX/m-p/762126#M241255</link>
      <description>&lt;P&gt;What happens if you open the XML before your conversion? Does it open fine then?&lt;/P&gt;
&lt;P&gt;Also, can you switch to using ODS EXCEL and avoid the conversion requirement entirely?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Also, what happens if you run the code below:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;

ods tagsets.excelxp file="H:\CDISC\ADaM\Data\Q2\forum_demo.xml";
proc print data=sashelp.class;
run;
ods tagsets.excelxp close;

%macro convert_files(default=,ext=);
data _null_;
file "'&amp;amp;default\temp.xlsx'";
put "set xlapp = CreateObject(""Excel.Application"")";
put "set fso = CreateObject(""scripting.filesystemobject"")";
put "set myfolder = fso.GetFolder(""&amp;amp;default"")";
put "set myfiles = myfolder.Files";
put "xlapp.DisplayAlerts = False";
put " ";
put "for each f in myfiles";
put "If f.Size &amp;lt; 70000 And fso.GetExtensionName(f)=""&amp;amp;ext"" Then";
put " f.Delete True";
put " End If";
put " Next";
put " ";
put "for each f in myfiles";
put " ExtName = fso.GetExtensionName(f)";
put " Filename= fso.GetBaseName(f)";
put " if ExtName=""&amp;amp;ext"" then";
put " set mybook = xlapp.Workbooks.Open(f.Path)";
put " xlapp.Visible = false";
put " mybook.SaveAs ""&amp;amp;default.\"" &amp;amp; Filename &amp;amp; "".xlsx"", 51";
put " End If";
put " Next";
put " mybook.Close";
put " xlapp.DisplayAlerts = True";
/* Removes original files */
put " FSO.DeleteFile(""&amp;amp;default\*.&amp;amp;ext""), DeleteReadOnly";
put " xlapp.Quit";
put " Set xlapp = Nothing";
put " strScript = Wscript.ScriptFullName";
put " FSO.DeleteFile(strScript)";
run;

x "cscript ""&amp;amp;default\temp.xlsx""";
%mend;

%convert_files(default=H:\CDISC\ADaM\Data\Q2,
ext=xml);

&lt;/CODE&gt;&lt;/PRE&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/393688"&gt;@Semie&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;I am trying to convert XML to excel file and got the code from the link below. I created the XML but when I run the code to convert to excel, a corrupted(blank) excel file is created, log looks clean. When I open the file, I got the massage in the screenshot below.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Could anyone help me if I miss any, please?&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Semie_0-1629217333190.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/62669i526BF1719A4EF162/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Semie_0-1629217333190.png" alt="Semie_0-1629217333190.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://communities.sas.com/t5/SAS-Procedures/Converting-XML-to-XLSX/td-p/142446" target="_blank" rel="noopener"&gt;https://communities.sas.com/t5/SAS-Procedures/Converting-XML-to-XLSX/td-p/142446&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here is the code I am using:&amp;nbsp;&lt;/P&gt;
&lt;P&gt;ods tagsets.excelxp file="&amp;amp;default\temp.xml" newfile=bygroup;&lt;BR /&gt;proc print data=test;&lt;BR /&gt;run;&lt;BR /&gt;ods tagsets.excelxp close;&lt;/P&gt;
&lt;P&gt;%macro convert_files(default=,ext=);&lt;BR /&gt;data _null_;&lt;BR /&gt;file "'&amp;amp;default\temp.xlsx'";&lt;BR /&gt;put "set xlapp = CreateObject(""Excel.Application"")";&lt;BR /&gt;put "set fso = CreateObject(""scripting.filesystemobject"")";&lt;BR /&gt;put "set myfolder = fso.GetFolder(""&amp;amp;default"")";&lt;BR /&gt;put "set myfiles = myfolder.Files";&lt;BR /&gt;put "xlapp.DisplayAlerts = False";&lt;BR /&gt;put " ";&lt;BR /&gt;put "for each f in myfiles";&lt;BR /&gt;put "If f.Size &amp;lt; 70000 And fso.GetExtensionName(f)=""&amp;amp;ext"" Then";&lt;BR /&gt;put " f.Delete True";&lt;BR /&gt;put " End If";&lt;BR /&gt;put " Next";&lt;BR /&gt;put " ";&lt;BR /&gt;put "for each f in myfiles";&lt;BR /&gt;put " ExtName = fso.GetExtensionName(f)";&lt;BR /&gt;put " Filename= fso.GetBaseName(f)";&lt;BR /&gt;put " if ExtName=""&amp;amp;ext"" then";&lt;BR /&gt;put " set mybook = xlapp.Workbooks.Open(f.Path)";&lt;BR /&gt;put " xlapp.Visible = false";&lt;BR /&gt;put " mybook.SaveAs ""&amp;amp;default.\"" &amp;amp; Filename &amp;amp; "".xlsx"", 51";&lt;BR /&gt;put " End If";&lt;BR /&gt;put " Next";&lt;BR /&gt;put " mybook.Close";&lt;BR /&gt;put " xlapp.DisplayAlerts = True";&lt;BR /&gt;/* Removes original files */&lt;BR /&gt;put " FSO.DeleteFile(""&amp;amp;default\*.&amp;amp;ext""), DeleteReadOnly";&lt;BR /&gt;put " xlapp.Quit";&lt;BR /&gt;put " Set xlapp = Nothing";&lt;BR /&gt;put " strScript = Wscript.ScriptFullName";&lt;BR /&gt;put " FSO.DeleteFile(strScript)";&lt;BR /&gt;run;&lt;BR /&gt;&lt;BR /&gt;x "cscript ""&amp;amp;default\temp.xlsx""";&lt;BR /&gt;%mend;&lt;/P&gt;
&lt;P&gt;%convert_files(default=H:\CDISC\ADaM\Data\Q2,&lt;BR /&gt;ext=xml);&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 17 Aug 2021 17:37:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Converting-XML-to-XLSX/m-p/762126#M241255</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2021-08-17T17:37:08Z</dc:date>
    </item>
    <item>
      <title>Re: Converting XML to XLSX</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Converting-XML-to-XLSX/m-p/762316#M241345</link>
      <description>&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;The XML file opens fine, I can see all the information as expected.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;If I use ODS EXCEL, the program crashes because the SAS dataset is very big, that is the reason I am creating XML and trying to convert to excel.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;I tried the code you updated, XML created and can be opened fine, the excel file is also generated but has NO information(just blank).&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;What could be the reason?&lt;/DIV&gt;</description>
      <pubDate>Wed, 18 Aug 2021 15:37:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Converting-XML-to-XLSX/m-p/762316#M241345</guid>
      <dc:creator>Semie</dc:creator>
      <dc:date>2021-08-18T15:37:33Z</dc:date>
    </item>
    <item>
      <title>Re: Converting XML to XLSX</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Converting-XML-to-XLSX/m-p/762326#M241352</link>
      <description>&lt;P&gt;Raise a support ticket with SAS to have them investigate your specific example to see why ODS EXCEL crashes.&lt;/P&gt;
&lt;P&gt;Make sure you are running a pretty recent release of SAS (&lt;A href="https://blogs.sas.com/content/iml/2013/08/02/how-old-is-your-version-of-sas-release-dates-for-sas-software.html" target="_blank"&gt;https://blogs.sas.com/content/iml/2013/08/02/how-old-is-your-version-of-sas-release-dates-for-sas-software.html&lt;/A&gt;).&amp;nbsp; The initial releases that included ODS EXCEL it was experimental (aka buggy).&lt;/P&gt;</description>
      <pubDate>Wed, 18 Aug 2021 16:17:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Converting-XML-to-XLSX/m-p/762326#M241352</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2021-08-18T16:17:00Z</dc:date>
    </item>
    <item>
      <title>Re: Converting XML to XLSX</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Converting-XML-to-XLSX/m-p/762349#M241362</link>
      <description>&lt;P&gt;You might try increasing -memsize to see if you can get ODS EXCEL to work.&amp;nbsp; See e.g. the comments in:&lt;/P&gt;
&lt;P&gt;&lt;A href="https://blogs.sas.com/content/sgf/2017/02/20/tips-for-using-the-ods-excel-destination/" target="_blank"&gt;https://blogs.sas.com/content/sgf/2017/02/20/tips-for-using-the-ods-excel-destination/&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But if it's huge data, you still might hit the memory limit.&amp;nbsp; (Of course if it's huge data, some might question the benefits of storing it in an Excel file).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 18 Aug 2021 17:01:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Converting-XML-to-XLSX/m-p/762349#M241362</guid>
      <dc:creator>Quentin</dc:creator>
      <dc:date>2021-08-18T17:01:12Z</dc:date>
    </item>
    <item>
      <title>Re: Converting XML to XLSX</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Converting-XML-to-XLSX/m-p/762353#M241364</link>
      <description>Go to the VBS code and run it manually instead, find the VBS file and double click it. See if that works but if not it may at least give you a better error.</description>
      <pubDate>Wed, 18 Aug 2021 17:09:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Converting-XML-to-XLSX/m-p/762353#M241364</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2021-08-18T17:09:08Z</dc:date>
    </item>
    <item>
      <title>Re: Converting XML to XLSX</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Converting-XML-to-XLSX/m-p/762654#M241486</link>
      <description>&lt;P&gt;I&amp;nbsp;&lt;SPAN&gt;went to the VBS code and run it manually, and received the massage below when I double click&amp;nbsp;on the file.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Does the code I am using look correct?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Semie_0-1629400248706.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/62744i2FE6758EB3D50B9D/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Semie_0-1629400248706.png" alt="Semie_0-1629400248706.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 19 Aug 2021 19:14:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Converting-XML-to-XLSX/m-p/762654#M241486</guid>
      <dc:creator>Semie</dc:creator>
      <dc:date>2021-08-19T19:14:08Z</dc:date>
    </item>
    <item>
      <title>Re: Converting XML to XLSX</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Converting-XML-to-XLSX/m-p/762660#M241489</link>
      <description>&lt;P&gt;Sounds like there is an EXCEL setting to no longer accept files with inappropriate extensions.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;When creating the XML file use .xml as the extension instead of .xlsx.&lt;/P&gt;</description>
      <pubDate>Thu, 19 Aug 2021 19:28:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Converting-XML-to-XLSX/m-p/762660#M241489</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2021-08-19T19:28:00Z</dc:date>
    </item>
    <item>
      <title>Re: Converting XML to XLSX</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Converting-XML-to-XLSX/m-p/776129#M246773</link>
      <description>Hi Reeza,&lt;BR /&gt;this is quite useful script. I have on question for one of the line for [put " mybook.SaveAs ""&amp;amp;default.\"" &amp;amp; Filename &amp;amp; "".xlsx"", 51";]&lt;BR /&gt;what the '51' stands for? do we have another option for this. because when I use this script to convert xml file to xlsx, some information lost.</description>
      <pubDate>Mon, 25 Oct 2021 05:02:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Converting-XML-to-XLSX/m-p/776129#M246773</guid>
      <dc:creator>h919g</dc:creator>
      <dc:date>2021-10-25T05:02:52Z</dc:date>
    </item>
    <item>
      <title>Re: Converting XML to XLSX</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Converting-XML-to-XLSX/m-p/776226#M246822</link>
      <description>51 specifies the XLSX file format type.&lt;BR /&gt;If you manually go in and Save As do you get the same issue?&lt;BR /&gt;&lt;BR /&gt;They're listed here: &lt;A href="https://docs.microsoft.com/en-us/office/vba/api/excel.xlfileformat" target="_blank"&gt;https://docs.microsoft.com/en-us/office/vba/api/excel.xlfileformat&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Mon, 25 Oct 2021 16:15:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Converting-XML-to-XLSX/m-p/776226#M246822</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2021-10-25T16:15:15Z</dc:date>
    </item>
  </channel>
</rss>

