<?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: Is there anyway to import a file xlsm to xlsx in SAS ? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Is-there-anyway-to-import-a-file-xlsm-to-xlsx-in-SAS/m-p/710110#M218531</link>
    <description>&lt;P&gt;Just tell EXPORT what SHEET to make.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But don't use EXPORT or IMPORT. Just use the XLSX engine.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;libname in xlsx "orignial.xlsm";
libname out xlsx "new.xlsx";
proc copy inlib=in outlib=out;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Fri, 08 Jan 2021 04:19:28 GMT</pubDate>
    <dc:creator>Tom</dc:creator>
    <dc:date>2021-01-08T04:19:28Z</dc:date>
    <item>
      <title>Is there anyway to import a file xlsm to xlsx in SAS ?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Is-there-anyway-to-import-a-file-xlsm-to-xlsx-in-SAS/m-p/709690#M218287</link>
      <description>&lt;P&gt;Hi experts!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I had a look from Google, some forums, but it seems that whether we can import xlsm to xlsx types are still under controversial.&lt;/P&gt;
&lt;P&gt;I am wondering if there is any solution to transform xlsm file to xlsx file in SAS so far? I mean, I can do it manually by saving function from Excel. However, I have around 65 files and it is not optimal to do it manually. Even in that case, I also can search some Escel VBA codes to change the type of files from xlsm to xlsx in one folder. However, I want to do something consistent (like know more about SAS and see how far SAS can go).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I wish I can receive your idea about that.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Warmest regards!&lt;/P&gt;
&lt;DIV id="eJOY__extension_root" class="eJOY__extension_root_class" style="all: unset;"&gt;&amp;nbsp;&lt;/DIV&gt;</description>
      <pubDate>Wed, 06 Jan 2021 19:48:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Is-there-anyway-to-import-a-file-xlsm-to-xlsx-in-SAS/m-p/709690#M218287</guid>
      <dc:creator>Phil_NZ</dc:creator>
      <dc:date>2021-01-06T19:48:19Z</dc:date>
    </item>
    <item>
      <title>Re: Is there anyway to import a file xlsm to xlsx in SAS ?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Is-there-anyway-to-import-a-file-xlsm-to-xlsx-in-SAS/m-p/709694#M218290</link>
      <description>&lt;P&gt;SAS isn't a tool for converting Excel file formats. You can read Excel worksheets into SAS datasets and you can write SAS datasets to Excel worksheets but there is no guarantee that if you read from one Excel workbook and write out to another that the "copy" will be the same as the original.&lt;/P&gt;</description>
      <pubDate>Wed, 06 Jan 2021 20:00:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Is-there-anyway-to-import-a-file-xlsm-to-xlsx-in-SAS/m-p/709694#M218290</guid>
      <dc:creator>SASKiwi</dc:creator>
      <dc:date>2021-01-06T20:00:09Z</dc:date>
    </item>
    <item>
      <title>Re: Is there anyway to import a file xlsm to xlsx in SAS ?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Is-there-anyway-to-import-a-file-xlsm-to-xlsx-in-SAS/m-p/709715#M218308</link>
      <description>&lt;P&gt;XLSM is just XLSX with some extra microsoft objects for storing macros.&amp;nbsp; You should be able to read the data in a XLSM file using the XLSX engine.&amp;nbsp; SAS cannot do anything with any macros you might have in there.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;libname x xlsx 'c:\downloads\test1.xlsm' ;
proc copy inlib=x outlib=work; run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 06 Jan 2021 20:59:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Is-there-anyway-to-import-a-file-xlsm-to-xlsx-in-SAS/m-p/709715#M218308</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2021-01-06T20:59:11Z</dc:date>
    </item>
    <item>
      <title>Re: Is there anyway to import a file xlsm to xlsx in SAS ?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Is-there-anyway-to-import-a-file-xlsm-to-xlsx-in-SAS/m-p/709775#M218342</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159"&gt;@Tom&lt;/a&gt;&amp;nbsp;and &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/88384"&gt;@Shmuel&lt;/a&gt;&amp;nbsp;, thank you for your notices, could you please tell me why this code does not work while I am trying to convert from xlsm to xlsx? Many thanks&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;options compress=yes reuse=yes;

options mergenoby=error;&lt;BR /&gt;

%macro ImportAndTranspose(
      File=
      , StartSheet=
      , EndSheet=
   );

	libname myxl xlsx &amp;amp;File.;
    /*line changed*/
   %local i;
   
   %do i = &amp;amp;StartSheet. %to &amp;amp;EndSheet.;

    %if &amp;amp;i=1 %then %do;

     data sheet&amp;amp;i.;
	  set myxl.sheet&amp;amp;i.;
      range= "Sheet1$A:X";
      getnames= yes;
	 run;

     proc sort data= sheet&amp;amp;i.;
      by Type;
     run;
	%end;
	/* A list of code afterwards to do while i &amp;lt;&amp;gt; 1*/

   %end;
   
%mend;

%ImportAndTranspose(
      File= C:\Users\pnguyen\Desktop\New folder\Argentina__.xlsm
      , StartSheet= 1
      , EndSheet= 5);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;The error log is&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;64          C:\Users\pnguyen\Desktop\New folder\Argentina__.xlsm
            _
            22
ERROR: Libref MYXL is not assigned.
ERROR: Error in the LIBNAME statement.
ERROR: Libref MYXL is not assigned.

ERROR 22-7: Invalid option name C.&lt;/CODE&gt;&lt;/PRE&gt;
&lt;DIV id="eJOY__extension_root" class="eJOY__extension_root_class" style="all: unset;"&gt;&amp;nbsp;&lt;/DIV&gt;</description>
      <pubDate>Thu, 07 Jan 2021 01:04:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Is-there-anyway-to-import-a-file-xlsm-to-xlsx-in-SAS/m-p/709775#M218342</guid>
      <dc:creator>Phil_NZ</dc:creator>
      <dc:date>2021-01-07T01:04:59Z</dc:date>
    </item>
    <item>
      <title>Re: Is there anyway to import a file xlsm to xlsx in SAS ?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Is-there-anyway-to-import-a-file-xlsm-to-xlsx-in-SAS/m-p/709779#M218345</link>
      <description>&lt;P&gt;Having line&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;libname myxl xlsm &amp;amp;File.;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;enables read a sheet by&amp;nbsp;&lt;STRONG&gt;set myxl.&amp;lt;sheet name&amp;gt;;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You cannot use this method when the engine is changed into &lt;STRONG&gt;xlsx&lt;/STRONG&gt;.&lt;/P&gt;
&lt;P&gt;I suggest to open the&amp;nbsp;&lt;STRONG&gt;xlsx&lt;/STRONG&gt; excel file and keep it as&amp;nbsp; a&amp;nbsp;&lt;STRONG&gt;xlsm&lt;/STRONG&gt; file.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 07 Jan 2021 01:49:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Is-there-anyway-to-import-a-file-xlsm-to-xlsx-in-SAS/m-p/709779#M218345</guid>
      <dc:creator>Shmuel</dc:creator>
      <dc:date>2021-01-07T01:49:48Z</dc:date>
    </item>
    <item>
      <title>Re: Is there anyway to import a file xlsm to xlsx in SAS ?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Is-there-anyway-to-import-a-file-xlsm-to-xlsx-in-SAS/m-p/709781#M218347</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/88384"&gt;@Shmuel&lt;/a&gt;&amp;nbsp;, thank you for your suggestion, but when I run it again, the problem still be there, I am wondering if there is anyway to sort it out.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;options compress=yes reuse=yes;

options mergenoby=error;
/* If a MERGE statement used w/o a BY statement, the LOG presents error message*/
%macro ImportAndTranspose(
      File=
      , StartSheet=
      , EndSheet=
   );

	libname myxl xlsm &amp;amp;File.;/*line changed*/
    
   %local i;
   
   %do i = &amp;amp;StartSheet. %to &amp;amp;EndSheet.;

    %if &amp;amp;i=1 %then %do;
	  set myxl.sheet&amp;amp;i.;/*line changed*/
      range= "Sheet1$A:X";
      getnames= yes;
	 run;

     proc sort data= sheet&amp;amp;i.;
      by Type;
     run;
	%end;
	/* A list of code afterwards to do while i &amp;lt;&amp;gt; 1*/

   %end;
   
%mend;

%ImportAndTranspose(
      File= C:\Users\pnguyen\Desktop\New folder\Argentina__.xlsm
      , StartSheet= 1
      , EndSheet= 5);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;The file is currently under xlsm format, and I also delete the line&amp;nbsp;&lt;/P&gt;
&lt;PRE class="language-sas"&gt;&lt;CODE&gt;data sheet&amp;amp;i.;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;DIV id="eJOY__extension_root" class="eJOY__extension_root_class" style="all: unset;"&gt;&amp;nbsp;&lt;/DIV&gt;</description>
      <pubDate>Thu, 07 Jan 2021 02:13:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Is-there-anyway-to-import-a-file-xlsm-to-xlsx-in-SAS/m-p/709781#M218347</guid>
      <dc:creator>Phil_NZ</dc:creator>
      <dc:date>2021-01-07T02:13:08Z</dc:date>
    </item>
    <item>
      <title>Re: Is there anyway to import a file xlsm to xlsx in SAS ?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Is-there-anyway-to-import-a-file-xlsm-to-xlsx-in-SAS/m-p/709785#M218349</link>
      <description>&lt;P&gt;This line in the body of your macro&lt;/P&gt;
&lt;LI-CODE lang="sas"&gt;libname myxl xlsx &amp;amp;File.;&lt;/LI-CODE&gt;
&lt;P&gt;Resolves to&lt;/P&gt;
&lt;LI-CODE lang="sas"&gt;libname myxl xlsx C:\Users\pnguyen\Desktop\New folder\Argentina__.xlsm;&lt;/LI-CODE&gt;
&lt;P&gt;With the value of your macro variable &amp;amp;file.&lt;/P&gt;
&lt;P&gt;The file name has to be quotes. So maybe&lt;/P&gt;
&lt;PRE&gt;libname myxl xlsx "&amp;amp;File.";&lt;/PRE&gt;
&lt;P&gt;would fix the Libname not assigned error.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Remember, you can set OPTIONS MPRINT; before running the macro to see the code as generated, which usually means the error messages make more sense.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 07 Jan 2021 02:30:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Is-there-anyway-to-import-a-file-xlsm-to-xlsx-in-SAS/m-p/709785#M218349</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2021-01-07T02:30:42Z</dc:date>
    </item>
    <item>
      <title>Re: Is there anyway to import a file xlsm to xlsx in SAS ?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Is-there-anyway-to-import-a-file-xlsm-to-xlsx-in-SAS/m-p/709791#M218353</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/88384"&gt;@Shmuel&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Having line&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;libname myxl xlsm &amp;amp;File.;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;enables read a sheet by&amp;nbsp;&lt;STRONG&gt;set myxl.&amp;lt;sheet name&amp;gt;;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You cannot use this method when the engine is changed into &lt;STRONG&gt;xlsx&lt;/STRONG&gt;.&lt;/P&gt;
&lt;P&gt;I suggest to open the&amp;nbsp;&lt;STRONG&gt;xlsx&lt;/STRONG&gt; excel file and keep it as&amp;nbsp; a&amp;nbsp;&lt;STRONG&gt;xlsm&lt;/STRONG&gt; file.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;That's exactly backwards. The engine is XLSX.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;125   libname x xlsx 'c:\downloads\test1.xlsm' ;
NOTE: Libref X was successfully assigned as follows:
      Engine:        XLSX
      Physical Name: c:\downloads\test1.xlsm
126   proc copy inlib=x outlib=work; run;

NOTE: Copying X.SHEET1 to WORK.SHEET1 (memtype=DATA).
NOTE: BUFSIZE is not cloned when copying across different engines. System Option for BUFSIZE was used.
NOTE: The import data set has 1 observations and 2 variables.
NOTE: There were 1 observations read from the data set X.SHEET1.
NOTE: The data set WORK.SHEET1 has 1 observations and 2 variables.
NOTE: Copying X.SHEET2 to WORK.SHEET2 (memtype=DATA).
NOTE: BUFSIZE is not cloned when copying across different engines. System Option for BUFSIZE was used.
NOTE: The import data set has 1 observations and 2 variables.
NOTE: There were 1 observations read from the data set X.SHEET2.
NOTE: The data set WORK.SHEET2 has 1 observations and 2 variables.
NOTE: Copying X.SHEET3 to WORK.SHEET3 (memtype=DATA).
NOTE: BUFSIZE is not cloned when copying across different engines. System Option for BUFSIZE was used.
NOTE: The import data set has 0 observations and 0 variables.
NOTE: There were 0 observations read from the data set X.SHEET3.
NOTE: The data set WORK.SHEET3 has 0 observations and 0 variables.
NOTE: PROCEDURE COPY used (Total process time):
      real time           0.15 seconds
      cpu time            0.06 seconds


127   libname x xlsm 'c:\downloads\test1.xlsm' ;
ERROR: The XLSM engine cannot be found.
ERROR: Error in the LIBNAME statement.
128   proc copy inlib=x outlib=work; run;

ERROR: Libref X is not assigned.
NOTE: Statements not processed because of errors noted above.
NOTE: PROCEDURE COPY used (Total process time):
      real time           0.02 seconds
      cpu time            0.01 seconds

NOTE: The SAS System stopped processing this step because of errors.
&lt;/PRE&gt;
&lt;P&gt;Note the real problem with the macro code was that the LIBNAME statement did not have quotes around the filename. Either add the quotes in the call to the macro or change the macro code to add the quotes.&lt;/P&gt;</description>
      <pubDate>Thu, 07 Jan 2021 03:34:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Is-there-anyway-to-import-a-file-xlsm-to-xlsx-in-SAS/m-p/709791#M218353</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2021-01-07T03:34:56Z</dc:date>
    </item>
    <item>
      <title>Re: Is there anyway to import a file xlsm to xlsx in SAS ?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Is-there-anyway-to-import-a-file-xlsm-to-xlsx-in-SAS/m-p/709831#M218377</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159"&gt;@Tom&lt;/a&gt;&amp;nbsp;,&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/212695"&gt;@Phil_NZ&lt;/a&gt;&amp;nbsp; - sorry for my confusion. I have checked it:&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;Engine XLSX enables read both XLSX and XLSM excel formats.&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;Engine XLSM is erroneous.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 07 Jan 2021 07:01:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Is-there-anyway-to-import-a-file-xlsm-to-xlsx-in-SAS/m-p/709831#M218377</guid>
      <dc:creator>Shmuel</dc:creator>
      <dc:date>2021-01-07T07:01:58Z</dc:date>
    </item>
    <item>
      <title>Re: Is there anyway to import a file xlsm to xlsx in SAS ?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Is-there-anyway-to-import-a-file-xlsm-to-xlsx-in-SAS/m-p/709894#M218408</link>
      <description>&lt;BR /&gt;proc import datafile="c:\temp\ATC.xlsm" out=code_list  replace;&lt;BR /&gt;run;&lt;BR /&gt;proc export data=code_list outfile="c:\temp\ATC.xlsx" dbms=xlsx replace;&lt;BR /&gt;run;</description>
      <pubDate>Thu, 07 Jan 2021 12:59:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Is-there-anyway-to-import-a-file-xlsm-to-xlsx-in-SAS/m-p/709894#M218408</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2021-01-07T12:59:29Z</dc:date>
    </item>
    <item>
      <title>Re: Is there anyway to import a file xlsm to xlsx in SAS ?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Is-there-anyway-to-import-a-file-xlsm-to-xlsx-in-SAS/m-p/710099#M218524</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/18408"&gt;@Ksharp&lt;/a&gt;&amp;nbsp;!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you very much for your solution, but this solution is doing well if the excel file (xlsm) has &lt;STRONG&gt;only one sheet&lt;/STRONG&gt;. In my case, I ran the same code with an "xlsm" Excel file with &lt;STRONG&gt;3 sheets&lt;/STRONG&gt; and it turned out with a "xlsx" file with &lt;STRONG&gt;only the first sheet&lt;/STRONG&gt;.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am wondering if the result aligns with your idea.&lt;/P&gt;
&lt;DIV id="eJOY__extension_root" class="eJOY__extension_root_class" style="all: unset;"&gt;&amp;nbsp;&lt;/DIV&gt;</description>
      <pubDate>Fri, 08 Jan 2021 02:22:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Is-there-anyway-to-import-a-file-xlsm-to-xlsx-in-SAS/m-p/710099#M218524</guid>
      <dc:creator>Phil_NZ</dc:creator>
      <dc:date>2021-01-08T02:22:14Z</dc:date>
    </item>
    <item>
      <title>Re: Is there anyway to import a file xlsm to xlsx in SAS ?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Is-there-anyway-to-import-a-file-xlsm-to-xlsx-in-SAS/m-p/710101#M218526</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13884"&gt;@ballardw&lt;/a&gt;&amp;nbsp;!&lt;/P&gt;
&lt;P&gt;Thank you very much for your help, but I also change a little bit to suit your suggestion but some errors still occur.&lt;/P&gt;
&lt;P&gt;The code is as below:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;options compress=yes reuse=yes;

options mergenoby=error;

OPTIONS MPRINT;

%macro ImportAndTranspose(
      File=
      , StartSheet=
      , EndSheet=
   );

	libname myxl xlsx "&amp;amp;File.";/*line changed*/
    
   %local i;
   
   %do i = &amp;amp;StartSheet. %to &amp;amp;EndSheet.;

    %if &amp;amp;i=1 %then %do;

	  set myxl.sheet&amp;amp;i.;/*line changed*/
      range= "Sheet1$A:X";
      getnames= yes;
	 run;

     proc sort data= sheet&amp;amp;i.;
      by Type;
     run;
	%end;
	/* A list of code afterwards to do while i &amp;lt;&amp;gt; 1*/

   %end;
   
%mend;

%ImportAndTranspose(
      File= C:\Users\pnguyen\Desktop\New folder\Argentina__.xlsm
      , StartSheet= 1
      , EndSheet= 5);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;The log file is as below:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;MPRINT(IMPORTANDTRANSPOSE):   libname myxl xlsx "C:\Users\pnguyen\Desktop\New folder\Argentina__.xlsm";
ERROR: Invalid physical name for library MYXL.
ERROR: Error in the LIBNAME statement.
MPRINT(IMPORTANDTRANSPOSE):   set myxl.sheet1;
MPRINT(IMPORTANDTRANSPOSE):   range= "Sheet1$A:X";
MPRINT(IMPORTANDTRANSPOSE):   getnames= yes;
MPRINT(IMPORTANDTRANSPOSE):   run;


MPRINT(IMPORTANDTRANSPOSE):   proc sort data= sheet1;
ERROR: File WORK.SHEET1.DATA does not exist.
MPRINT(IMPORTANDTRANSPOSE):   by Type;
MPRINT(IMPORTANDTRANSPOSE):   run;

NOTE: The SAS System stopped processing this step because of errors.&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;I cross-check and see that the physical file is still there is this folder, I am wondering why they still announce that "Invalid physical name for library MYXL"&lt;/P&gt;
&lt;P&gt;Best regards!&lt;/P&gt;
&lt;DIV id="eJOY__extension_root" class="eJOY__extension_root_class" style="all: unset;"&gt;&amp;nbsp;&lt;/DIV&gt;</description>
      <pubDate>Fri, 08 Jan 2021 02:30:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Is-there-anyway-to-import-a-file-xlsm-to-xlsx-in-SAS/m-p/710101#M218526</guid>
      <dc:creator>Phil_NZ</dc:creator>
      <dc:date>2021-01-08T02:30:32Z</dc:date>
    </item>
    <item>
      <title>Re: Is there anyway to import a file xlsm to xlsx in SAS ?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Is-there-anyway-to-import-a-file-xlsm-to-xlsx-in-SAS/m-p/710103#M218527</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/212695"&gt;@Phil_NZ&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/18408"&gt;@Ksharp&lt;/a&gt;&amp;nbsp;!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you very much for your solution, but this solution is doing well if the excel file (xlsm) has &lt;STRONG&gt;only one sheet&lt;/STRONG&gt;. In my case, I ran the same code with an "xlsm" Excel file with &lt;STRONG&gt;3 sheets&lt;/STRONG&gt; and it turned out with a "xlsx" file with &lt;STRONG&gt;only the first sheet&lt;/STRONG&gt;.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am wondering if the result aligns with your idea.&lt;/P&gt;
&lt;DIV id="eJOY__extension_root" class="eJOY__extension_root_class" style="all: unset;"&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Export at heart pretty much wants to write a single "page" of output. It was designed with text files in mind. As such I'm not sure that you can get&lt;/P&gt;</description>
      <pubDate>Fri, 08 Jan 2021 02:58:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Is-there-anyway-to-import-a-file-xlsm-to-xlsx-in-SAS/m-p/710103#M218527</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2021-01-08T02:58:40Z</dc:date>
    </item>
    <item>
      <title>Re: Is there anyway to import a file xlsm to xlsx in SAS ?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Is-there-anyway-to-import-a-file-xlsm-to-xlsx-in-SAS/m-p/710110#M218531</link>
      <description>&lt;P&gt;Just tell EXPORT what SHEET to make.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But don't use EXPORT or IMPORT. Just use the XLSX engine.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;libname in xlsx "orignial.xlsm";
libname out xlsx "new.xlsx";
proc copy inlib=in outlib=out;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 08 Jan 2021 04:19:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Is-there-anyway-to-import-a-file-xlsm-to-xlsx-in-SAS/m-p/710110#M218531</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2021-01-08T04:19:28Z</dc:date>
    </item>
    <item>
      <title>Re: Is there anyway to import a file xlsm to xlsx in SAS ?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Is-there-anyway-to-import-a-file-xlsm-to-xlsx-in-SAS/m-p/710112#M218533</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159"&gt;@Tom&lt;/a&gt;&amp;nbsp;!&lt;/P&gt;
&lt;P&gt;Thank you for your suggestion, I have tried and it still announce errors as below&lt;/P&gt;
&lt;P&gt;My code is&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;OPTIONS MPRINT;
libname in xlsx "C:\Users\pnguyen\Desktop\New folder\Argentina__.xlsm";
libname out xlsx "C:\Users\pnguyen\Desktop\New folder\Argentina__.xlsx";
proc copy inlib=in outlib=out;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;The log is:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;28         OPTIONS MPRINT;
29         libname in xlsx "C:\Users\pnguyen\Desktop\New folder\Argentina__.xlsm";
ERROR: Invalid physical name for library IN.
ERROR: Error in the LIBNAME statement.
30         libname out xlsx "C:\Users\pnguyen\Desktop\New folder\Argentina__.xlsx";
NOTE: Libref OUT was successfully assigned as follows: 
      Engine:        XLSX 
      Physical Name: C:\Users\pnguyen\Desktop\New folder\Argentina__.xlsx


31         proc copy inlib=in outlib=out;
32         run;

ERROR: Libref IN is not assigned.&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;I am wondering if I haven't got your idea correctly?&lt;/P&gt;
&lt;P&gt;Many thanks!&lt;/P&gt;</description>
      <pubDate>Fri, 08 Jan 2021 04:24:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Is-there-anyway-to-import-a-file-xlsm-to-xlsx-in-SAS/m-p/710112#M218533</guid>
      <dc:creator>Phil_NZ</dc:creator>
      <dc:date>2021-01-08T04:24:28Z</dc:date>
    </item>
    <item>
      <title>Re: Is there anyway to import a file xlsm to xlsx in SAS ?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Is-there-anyway-to-import-a-file-xlsm-to-xlsx-in-SAS/m-p/710113#M218534</link>
      <description>&lt;P&gt;I got a different error. Perhaps PROC COPY is trying to do something strange?&lt;/P&gt;
&lt;P&gt;Anyway it worked when it first copied to actual SAS datasets.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;libname in xlsx 'c:\downloads\test1.xlsm';
libname out xlsx 'c:\downloads\test1.xlsx';

proc datasets nolist kill lib=work mt=data; run;

proc copy inlib=in outlib=work; run;
proc copy inlib=work outlib=out mt=data; run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 08 Jan 2021 04:42:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Is-there-anyway-to-import-a-file-xlsm-to-xlsx-in-SAS/m-p/710113#M218534</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2021-01-08T04:42:26Z</dc:date>
    </item>
    <item>
      <title>Re: Is there anyway to import a file xlsm to xlsx in SAS ?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Is-there-anyway-to-import-a-file-xlsm-to-xlsx-in-SAS/m-p/710114#M218535</link>
      <description>&lt;P&gt;So, in general:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;When I run the&amp;nbsp; code:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc import datafile="C:\Users\pnguyen\Desktop\New folder\Argentina__.xlsm" out=code_list replace;
run;
proc export data=code_list outfile="C:\Users\pnguyen\Desktop\New folder\Argentina__.xlsx" dbms=xlsx replace;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;It will generate a new xlsx file in the folder named (New Folder) with only sheet1 (among 5 sheets in total)&lt;/P&gt;
&lt;P&gt;When I run the code with libname:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;OPTIONS MPRINT;
libname in xlsx 'C:\Users\pnguyen\Desktop\New folder\Argentina__.xlsm';
libname out xlsx 'C:\Users\pnguyen\Desktop\New folder\Argentina__.xlsx';
proc copy inlib=in outlib=out;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;It turned out the error as below:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;28         libname in xlsx 'C:\Users\pnguyen\Desktop\New folder\Argentina__.xlsm';
ERROR: Invalid physical name for library IN.
ERROR: Error in the LIBNAME statement.
29         libname out xlsx 'C:\Users\pnguyen\Desktop\New folder\Argentina__.xlsx';
NOTE: Libref OUT was successfully assigned as follows: 
      Engine:        XLSX 
      Physical Name: C:\Users\pnguyen\Desktop\New folder\Argentina__.xlsx


30         proc copy inlib=in outlib=out;
31         run;

ERROR: Libref IN is not assigned.&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;And I am not sure I can you call sheet 1, or sheet2 from the code of libname approach, can you please give me a hint, I am really into this way of doing thing?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Many thanks and best regards.&lt;/P&gt;
&lt;DIV id="eJOY__extension_root" class="eJOY__extension_root_class" style="all: unset;"&gt;&amp;nbsp;&lt;/DIV&gt;</description>
      <pubDate>Fri, 08 Jan 2021 04:47:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Is-there-anyway-to-import-a-file-xlsm-to-xlsx-in-SAS/m-p/710114#M218535</guid>
      <dc:creator>Phil_NZ</dc:creator>
      <dc:date>2021-01-08T04:47:03Z</dc:date>
    </item>
    <item>
      <title>Re: Is there anyway to import a file xlsm to xlsx in SAS ?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Is-there-anyway-to-import-a-file-xlsm-to-xlsx-in-SAS/m-p/710115#M218536</link>
      <description>&lt;P&gt;Thanks&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159"&gt;@Tom&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It is quite interesting to me, even I tried the new code suggested, it still turned out the same error, so it maybe because of the PROC COPY, I deem&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;OPTIONS MPRINT;
libname in xlsx 'C:\Users\pnguyen\Desktop\New folder\Argentina__.xlsm';
libname out xlsx 'C:\Users\pnguyen\Desktop\New folder\Argentina__.xlsx';
proc datasets nolist kill lib=work mt=data; run;

proc copy inlib=in outlib=work; run;
proc copy inlib=work outlib=out mt=data; run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Log:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;28         OPTIONS MPRINT;
29         libname in xlsx 'C:\Users\pnguyen\Desktop\New folder\Argentina__.xlsm';
ERROR: Invalid physical name for library IN.
ERROR: Error in the LIBNAME statement.
30         libname out xlsx 'C:\Users\pnguyen\Desktop\New folder\Argentina__.xlsx';
NOTE: Libref OUT was successfully assigned as follows: 
      Engine:        XLSX 
      Physical Name: C:\Users\pnguyen\Desktop\New folder\Argentina__.xlsx
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Many thanks!&lt;/P&gt;
&lt;DIV id="eJOY__extension_root" class="eJOY__extension_root_class" style="all: unset;"&gt;&amp;nbsp;&lt;/DIV&gt;</description>
      <pubDate>Fri, 08 Jan 2021 04:50:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Is-there-anyway-to-import-a-file-xlsm-to-xlsx-in-SAS/m-p/710115#M218536</guid>
      <dc:creator>Phil_NZ</dc:creator>
      <dc:date>2021-01-08T04:50:52Z</dc:date>
    </item>
    <item>
      <title>Re: Is there anyway to import a file xlsm to xlsx in SAS ?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Is-there-anyway-to-import-a-file-xlsm-to-xlsx-in-SAS/m-p/710119#M218537</link>
      <description>&lt;P&gt;The error message is very specific and strange.&amp;nbsp; Try copying or renaming the file.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Also what version of SAS are you running?&lt;/P&gt;
&lt;PRE&gt;124   %put &amp;amp;sysvlong;
9.04.01M5P091317
&lt;/PRE&gt;
&lt;P&gt;What version of Excel made the file?&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="image.png" style="width: 459px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/53296iA0D4C3A708203679/image-size/large?v=v2&amp;amp;px=999" role="button" title="image.png" alt="image.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 08 Jan 2021 05:18:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Is-there-anyway-to-import-a-file-xlsm-to-xlsx-in-SAS/m-p/710119#M218537</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2021-01-08T05:18:43Z</dc:date>
    </item>
    <item>
      <title>Re: Is there anyway to import a file xlsm to xlsx in SAS ?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Is-there-anyway-to-import-a-file-xlsm-to-xlsx-in-SAS/m-p/710121#M218538</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159"&gt;@Tom&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am using SAS EG 8.2 (32 bit)&lt;/P&gt;
&lt;P&gt;My Excel version is:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="My97_0-1610083381644.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/53297iCA7A3B87C2CB64E7/image-size/medium?v=v2&amp;amp;px=400" role="button" title="My97_0-1610083381644.png" alt="My97_0-1610083381644.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;I also attach the file (xlsx) and you can convert to xlsm by saving as and test in case&lt;/P&gt;
&lt;P&gt;Many thanks and regards!&lt;/P&gt;
&lt;DIV id="eJOY__extension_root" class="eJOY__extension_root_class" style="all: unset;"&gt;&amp;nbsp;&lt;/DIV&gt;</description>
      <pubDate>Fri, 08 Jan 2021 05:25:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Is-there-anyway-to-import-a-file-xlsm-to-xlsx-in-SAS/m-p/710121#M218538</guid>
      <dc:creator>Phil_NZ</dc:creator>
      <dc:date>2021-01-08T05:25:18Z</dc:date>
    </item>
  </channel>
</rss>

