<?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 convert XML (named as XLS) to XLSX? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-convert-XML-named-as-XLS-to-XLSX/m-p/345664#M79551</link>
    <description>&lt;P&gt;Maybe you want this PROC.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;PROC XSL transforms an XML document into another format, such as HTML, text,&lt;BR /&gt;or another XML document type. PROC XSL reads an input XML document, transforms&lt;BR /&gt;it by using an XSL style sheet, and then writes an output file.&lt;/P&gt;</description>
    <pubDate>Thu, 30 Mar 2017 07:20:59 GMT</pubDate>
    <dc:creator>Ksharp</dc:creator>
    <dc:date>2017-03-30T07:20:59Z</dc:date>
    <item>
      <title>How to convert XML (named as XLS) to XLSX?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-convert-XML-named-as-XLS-to-XLSX/m-p/345637#M79541</link>
      <description>&lt;P&gt;Hi, I am using SAS 9.3.&lt;/P&gt;&lt;P&gt;According the following program, how to convert XML (named XLS) to XLSX?&amp;nbsp;&lt;/P&gt;&lt;P&gt;(Creating XML named as XLS is fixed.)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro convert_files(default=,ext=);
 
data _null_;
file "'&amp;amp;default\temp.vbs'";
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 "  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.vbs""";
 
%mend;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Before that I created a file by ODS TAGSETS.EXCELXP file="&amp;amp;path.\have.&lt;FONT color="#FF0000"&gt;XLS&lt;/FONT&gt;";&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;And then, I expect the code will be "%convert_files(default=&amp;amp;path.,ext=&lt;FONT color="#FF0000"&gt;XLS&lt;/FONT&gt;);&lt;/P&gt;&lt;P&gt;But it does not work! Does anyone have the suggestions to modify the program above?&lt;/P&gt;</description>
      <pubDate>Thu, 30 Mar 2017 03:49:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-convert-XML-named-as-XLS-to-XLSX/m-p/345637#M79541</guid>
      <dc:creator>JohnChen_TW</dc:creator>
      <dc:date>2017-03-30T03:49:01Z</dc:date>
    </item>
    <item>
      <title>Re: How to convert XML (named as XLS) to XLSX?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-convert-XML-named-as-XLS-to-XLSX/m-p/345651#M79545</link>
      <description>&lt;P&gt;What does 'not working' mean?&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Was the vb script created? What happens if you run that from Windows portion?&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 30 Mar 2017 05:31:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-convert-XML-named-as-XLS-to-XLSX/m-p/345651#M79545</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-03-30T05:31:30Z</dc:date>
    </item>
    <item>
      <title>Re: How to convert XML (named as XLS) to XLSX?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-convert-XML-named-as-XLS-to-XLSX/m-p/345652#M79546</link>
      <description>Vb script was created but the XLS is not converted to XLSX.&lt;BR /&gt;If ext=XML and it will be converted to a XLSX file.</description>
      <pubDate>Thu, 30 Mar 2017 05:53:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-convert-XML-named-as-XLS-to-XLSX/m-p/345652#M79546</guid>
      <dc:creator>JohnChen_TW</dc:creator>
      <dc:date>2017-03-30T05:53:39Z</dc:date>
    </item>
    <item>
      <title>Re: How to convert XML (named as XLS) to XLSX?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-convert-XML-named-as-XLS-to-XLSX/m-p/345664#M79551</link>
      <description>&lt;P&gt;Maybe you want this PROC.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;PROC XSL transforms an XML document into another format, such as HTML, text,&lt;BR /&gt;or another XML document type. PROC XSL reads an input XML document, transforms&lt;BR /&gt;it by using an XSL style sheet, and then writes an output file.&lt;/P&gt;</description>
      <pubDate>Thu, 30 Mar 2017 07:20:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-convert-XML-named-as-XLS-to-XLSX/m-p/345664#M79551</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2017-03-30T07:20:59Z</dc:date>
    </item>
    <item>
      <title>Re: How to convert XML (named as XLS) to XLSX?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-convert-XML-named-as-XLS-to-XLSX/m-p/345682#M79559</link>
      <description>&lt;P&gt;Hi Ksharp,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for your reply.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Please see the whole program below.&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let path=C:\Users\john.chen\Desktop;

data class; set sashelp.class; run;

ods tagsets.excelxp file="&amp;amp;path\temp.XLS" Style=my.style;
proc report data=class nowd
contents="Table of Contents";
	columns Name Sex Age Height Weight;
	define Name 	/'Name';
	define Sex 	/'Sex';
	define Age 	/'Age';
	define Height 	/'Height';
	define Weight 	/'Weight'; 
run;
ods tagsets.excelxp close;

%convert_files(default=&amp;amp;path,ext=XLS);

/*------------------------------Convert () to XLSX--------------------------------*/
 options noxwait noxsync; 
 
%macro convert_files(default=,ext=);
 
data _null_;
file "'&amp;amp;default\temp.vbs'";
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 "  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.vbs""";
 
%mend;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;STRONG&gt;ods tagsets.excelxp file="&amp;amp;path\temp.&lt;FONT color="#FF0000"&gt;XLS&lt;/FONT&gt;" Style=my.style;&lt;/STRONG&gt; is needed and cannot be revised.&lt;/P&gt;&lt;P&gt;I know this code does create XML file instead of excel.XLS file ,and this file would later complains when opening it. So I need to transform it into an XLSX file to import it. As I know, the macro above can work when using ext=&lt;FONT color="#FF0000"&gt;XML&lt;/FONT&gt;.&lt;/P&gt;&lt;P&gt;How to conver temp.XLS to XLSX file in this&amp;nbsp;case? Does PROC XSL can resolve this case?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;(Becasue I've never used PROC XSL before, I have no idea how to do...)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;JC&lt;/P&gt;</description>
      <pubDate>Thu, 30 Mar 2017 08:29:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-convert-XML-named-as-XLS-to-XLSX/m-p/345682#M79559</guid>
      <dc:creator>JohnChen_TW</dc:creator>
      <dc:date>2017-03-30T08:29:24Z</dc:date>
    </item>
    <item>
      <title>Re: How to convert XML (named as XLS) to XLSX?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-convert-XML-named-as-XLS-to-XLSX/m-p/345687#M79561</link>
      <description>&lt;P&gt;I knew there is a macro in support.sas.com can do this.&lt;/P&gt;
&lt;P&gt;Search it at support.sas.com&lt;/P&gt;
&lt;P&gt;keywords are &amp;nbsp;tagsets.excelxp &amp;nbsp;native excel&lt;/P&gt;</description>
      <pubDate>Thu, 30 Mar 2017 08:37:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-convert-XML-named-as-XLS-to-XLSX/m-p/345687#M79561</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2017-03-30T08:37:22Z</dc:date>
    </item>
    <item>
      <title>Re: How to convert XML (named as XLS) to XLSX?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-convert-XML-named-as-XLS-to-XLSX/m-p/345725#M79577</link>
      <description>&lt;P&gt;What happens if you run the VB script from Windows side? If there's an error it should be in the window.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Or open the script in a text editor and see what's wrong.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 30 Mar 2017 12:27:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-convert-XML-named-as-XLS-to-XLSX/m-p/345725#M79577</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-03-30T12:27:24Z</dc:date>
    </item>
    <item>
      <title>Re: How to convert XML (named as XLS) to XLSX?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-convert-XML-named-as-XLS-to-XLSX/m-p/345737#M79580</link>
      <description>&lt;P&gt;Your steps are out of order in this post. &amp;nbsp;You cannot call the macro before you have compiled it.&lt;/P&gt;</description>
      <pubDate>Thu, 30 Mar 2017 13:08:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-convert-XML-named-as-XLS-to-XLSX/m-p/345737#M79580</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2017-03-30T13:08:28Z</dc:date>
    </item>
    <item>
      <title>Re: How to convert XML (named as XLS) to XLSX?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-convert-XML-named-as-XLS-to-XLSX/m-p/345773#M79602</link>
      <description>No, the macro under the dotted line above is just shown what "%convert_files" does, not runs after called it.</description>
      <pubDate>Thu, 30 Mar 2017 14:45:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-convert-XML-named-as-XLS-to-XLSX/m-p/345773#M79602</guid>
      <dc:creator>JohnChen_TW</dc:creator>
      <dc:date>2017-03-30T14:45:06Z</dc:date>
    </item>
  </channel>
</rss>

