BookmarkSubscribeRSS Feed
Tom
Super User Tom
Super User

I got a different error. Perhaps PROC COPY is trying to do something strange?

Anyway it worked when it first copied to actual SAS datasets.

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;
Phil_NZ
Barite | Level 11

Thanks @Tom 

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

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;

Log:

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

Many thanks!

 
Thank you for your help, have a fabulous and productive day! I am a novice today, but someday when I accumulate enough knowledge, I can help others in my capacity.
Tom
Super User Tom
Super User

The error message is very specific and strange.  Try copying or renaming the file.

 

Also what version of SAS are you running?

124   %put &sysvlong;
9.04.01M5P091317

What version of Excel made the file?

image.png

 

Phil_NZ
Barite | Level 11

Hi @Tom 

I am using SAS EG 8.2 (32 bit)

My Excel version is:

My97_0-1610083381644.png

I also attach the file (xlsx) and you can convert to xlsm by saving as and test in case

Many thanks and regards!

 
Thank you for your help, have a fabulous and productive day! I am a novice today, but someday when I accumulate enough knowledge, I can help others in my capacity.
Tom
Super User Tom
Super User

What version of Enterprise Guide (or any other user interface you might be using to submit the SAS code) does not matter. 

The version of SAS that you are using to run your code is what matters.

Just run the one line %PUT statement to see the version you are using.  You can also probably see the version by checking the information on the connection to SAS in Enterprise Guide.

Phil_NZ
Barite | Level 11

Hi @Tom 

The code results in the version of SAS as below

1    %put &sysvlong;
9.04.01M6P110718

I am wondering if there is anything special with this version then!

Many thanks and cheers!

 
Thank you for your help, have a fabulous and productive day! I am a novice today, but someday when I accumulate enough knowledge, I can help others in my capacity.
Tom
Super User Tom
Super User

No idea what a "remote library" means in this case.  Perhaps it means the file is on a network share?

If so try copying the file to another location, perhaps the SAS WORK directory, and see if the XLSX engine works.

Kurt_Bremser
Super User

I also find that the Note is very terse and should have more detailed information. But it is the #1 mention on the internet of the ERROR message, and @Phil_NZ's SAS version is 9.4M6, see here.

Tom
Super User Tom
Super User

I resaved your file as XLSM format in Excel and it works file.

154   libname in xlsx "c:\downloads\Argentina__.xlsm" ;
NOTE: Libref IN was successfully assigned as follows:
      Engine:        XLSX
      Physical Name: c:\downloads\Argentina__.xlsm
155   proc copy inlib=in outlib=work; run;

NOTE: Copying IN.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 453 observations and 6 variables.
NOTE: There were 453 observations read from the data set IN.SHEET1.
NOTE: The data set WORK.SHEET1 has 453 observations and 6 variables.
NOTE: Copying IN.SHEET2 to WORK.SHEET2 (memtype=DATA).
NOTE:    Variable Name Change.  1988 -> _1988
NOTE:    Variable Name Change.  1989 -> _1989
NOTE:    Variable Name Change.  1990 -> _1990
NOTE:    Variable Name Change.  1991 -> _1991
NOTE:    Variable Name Change.  1992 -> _1992
NOTE:    Variable Name Change.  1993 -> _1993
NOTE:    Variable Name Change.  1994 -> _1994
NOTE:    Variable Name Change.  1995 -> _1995
NOTE:    Variable Name Change.  1996 -> _1996
NOTE:    Variable Name Change.  1997 -> _1997
NOTE:    Variable Name Change.  1998 -> _1998
NOTE:    Variable Name Change.  1999 -> _1999
NOTE:    Variable Name Change.  2000 -> _2000
NOTE:    Variable Name Change.  2001 -> _2001
NOTE:    Variable Name Change.  2002 -> _2002
NOTE:    Variable Name Change.  2003 -> _2003
NOTE:    Variable Name Change.  2004 -> _2004
NOTE:    Variable Name Change.  2005 -> _2005
NOTE:    Variable Name Change.  2006 -> _2006
NOTE:    Variable Name Change.  2007 -> _2007
NOTE:    Variable Name Change.  2008 -> _2008
NOTE:    Variable Name Change.  2009 -> _2009
NOTE:    Variable Name Change.  2010 -> _2010
NOTE:    Variable Name Change.  2011 -> _2011
NOTE:    Variable Name Change.  2012 -> _2012
NOTE:    Variable Name Change.  2013 -> _2013
NOTE:    Variable Name Change.  2014 -> _2014
NOTE:    Variable Name Change.  2015 -> _2015
NOTE:    Variable Name Change.  2016 -> _2016
NOTE:    Variable Name Change.  2017 -> _2017
NOTE:    Variable Name Change.  2018 -> _2018
NOTE:    Variable Name Change.  2019 -> _2019
NOTE: BUFSIZE is not cloned when copying across different engines. System Option for BUFSIZE was used.
NOTE: The import data set has 453 observations and 36 variables.
NOTE: There were 453 observations read from the data set IN.SHEET2.
NOTE: The data set WORK.SHEET2 has 453 observations and 36 variables.
NOTE: Copying IN.SHEET3 to WORK.SHEET3 (memtype=DATA).
NOTE:    Variable Name Change.  1988 -> _1988
NOTE:    Variable Name Change.  1989 -> _1989
NOTE:    Variable Name Change.  1990 -> _1990
NOTE:    Variable Name Change.  1991 -> _1991
NOTE:    Variable Name Change.  1992 -> _1992
NOTE:    Variable Name Change.  1993 -> _1993
NOTE:    Variable Name Change.  1994 -> _1994
NOTE:    Variable Name Change.  1995 -> _1995
NOTE:    Variable Name Change.  1996 -> _1996
NOTE:    Variable Name Change.  1997 -> _1997
NOTE:    Variable Name Change.  1998 -> _1998
NOTE:    Variable Name Change.  1999 -> _1999
NOTE:    Variable Name Change.  2000 -> _2000
NOTE:    Variable Name Change.  2001 -> _2001
NOTE:    Variable Name Change.  2002 -> _2002
NOTE:    Variable Name Change.  2003 -> _2003
NOTE:    Variable Name Change.  2004 -> _2004
NOTE:    Variable Name Change.  2005 -> _2005
NOTE:    Variable Name Change.  2006 -> _2006
NOTE:    Variable Name Change.  2007 -> _2007
NOTE:    Variable Name Change.  2008 -> _2008
NOTE:    Variable Name Change.  2009 -> _2009
NOTE:    Variable Name Change.  2010 -> _2010
NOTE:    Variable Name Change.  2011 -> _2011
NOTE:    Variable Name Change.  2012 -> _2012
NOTE:    Variable Name Change.  2013 -> _2013
NOTE:    Variable Name Change.  2014 -> _2014
NOTE:    Variable Name Change.  2015 -> _2015
NOTE:    Variable Name Change.  2016 -> _2016
NOTE:    Variable Name Change.  2017 -> _2017
NOTE:    Variable Name Change.  2018 -> _2018
NOTE:    Variable Name Change.  2019 -> _2019
NOTE: BUFSIZE is not cloned when copying across different engines. System Option for BUFSIZE was used.
NOTE: The import data set has 453 observations and 36 variables.
NOTE: There were 453 observations read from the data set IN.SHEET3.
NOTE: The data set WORK.SHEET3 has 453 observations and 36 variables.
NOTE: Copying IN.SHEET4 to WORK.SHEET4 (memtype=DATA).
NOTE:    Variable Name Change.  1988 -> _1988
NOTE:    Variable Name Change.  1989 -> _1989
NOTE:    Variable Name Change.  1990 -> _1990
NOTE:    Variable Name Change.  1991 -> _1991
NOTE:    Variable Name Change.  1992 -> _1992
NOTE:    Variable Name Change.  1993 -> _1993
NOTE:    Variable Name Change.  1994 -> _1994
NOTE:    Variable Name Change.  1995 -> _1995
NOTE:    Variable Name Change.  1996 -> _1996
NOTE:    Variable Name Change.  1997 -> _1997
NOTE:    Variable Name Change.  1998 -> _1998
NOTE:    Variable Name Change.  1999 -> _1999
NOTE:    Variable Name Change.  2000 -> _2000
NOTE:    Variable Name Change.  2001 -> _2001
NOTE:    Variable Name Change.  2002 -> _2002
NOTE:    Variable Name Change.  2003 -> _2003
NOTE:    Variable Name Change.  2004 -> _2004
NOTE:    Variable Name Change.  2005 -> _2005
NOTE:    Variable Name Change.  2006 -> _2006
NOTE:    Variable Name Change.  2007 -> _2007
NOTE:    Variable Name Change.  2008 -> _2008
NOTE:    Variable Name Change.  2009 -> _2009
NOTE:    Variable Name Change.  2010 -> _2010
NOTE:    Variable Name Change.  2011 -> _2011
NOTE:    Variable Name Change.  2012 -> _2012
NOTE:    Variable Name Change.  2013 -> _2013
NOTE:    Variable Name Change.  2014 -> _2014
NOTE:    Variable Name Change.  2015 -> _2015
NOTE:    Variable Name Change.  2016 -> _2016
NOTE:    Variable Name Change.  2017 -> _2017
NOTE:    Variable Name Change.  2018 -> _2018
NOTE:    Variable Name Change.  2019 -> _2019
NOTE: BUFSIZE is not cloned when copying across different engines. System Option for BUFSIZE was used.
NOTE: The import data set has 453 observations and 36 variables.
NOTE: There were 453 observations read from the data set IN.SHEET4.
NOTE: The data set WORK.SHEET4 has 453 observations and 36 variables.
NOTE: Copying IN.SHEET5 to WORK.SHEET5 (memtype=DATA).
NOTE:    Variable Name Change.  1988 -> _1988
NOTE:    Variable Name Change.  1989 -> _1989
NOTE:    Variable Name Change.  1990 -> _1990
NOTE:    Variable Name Change.  1991 -> _1991
NOTE:    Variable Name Change.  1992 -> _1992
NOTE:    Variable Name Change.  1993 -> _1993
NOTE:    Variable Name Change.  1994 -> _1994
NOTE:    Variable Name Change.  1995 -> _1995
NOTE:    Variable Name Change.  1996 -> _1996
NOTE:    Variable Name Change.  1997 -> _1997
NOTE:    Variable Name Change.  1998 -> _1998
NOTE:    Variable Name Change.  1999 -> _1999
NOTE:    Variable Name Change.  2000 -> _2000
NOTE:    Variable Name Change.  2001 -> _2001
NOTE:    Variable Name Change.  2002 -> _2002
NOTE:    Variable Name Change.  2003 -> _2003
NOTE:    Variable Name Change.  2004 -> _2004
NOTE:    Variable Name Change.  2005 -> _2005
NOTE:    Variable Name Change.  2006 -> _2006
NOTE:    Variable Name Change.  2007 -> _2007
NOTE:    Variable Name Change.  2008 -> _2008
NOTE:    Variable Name Change.  2009 -> _2009
NOTE:    Variable Name Change.  2010 -> _2010
NOTE:    Variable Name Change.  2011 -> _2011
NOTE:    Variable Name Change.  2012 -> _2012
NOTE:    Variable Name Change.  2013 -> _2013
NOTE:    Variable Name Change.  2014 -> _2014
NOTE:    Variable Name Change.  2015 -> _2015
NOTE:    Variable Name Change.  2016 -> _2016
NOTE:    Variable Name Change.  2017 -> _2017
NOTE:    Variable Name Change.  2018 -> _2018
NOTE:    Variable Name Change.  2019 -> _2019
NOTE: BUFSIZE is not cloned when copying across different engines. System Option for BUFSIZE was used.
NOTE: The import data set has 453 observations and 36 variables.
NOTE: There were 453 observations read from the data set IN.SHEET5.
NOTE: The data set WORK.SHEET5 has 453 observations and 36 variables.
NOTE: PROCEDURE COPY used (Total process time):
      real time           0.45 seconds
      cpu time            0.43 seconds

Phil_NZ
Barite | Level 11

So, in general:

 

When I run the  code:

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;

It will generate a new xlsx file in the folder named (New Folder) with only sheet1 (among 5 sheets in total)

When I run the code with libname:

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;

It turned out the error as below:

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.

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?

 

Many thanks and best regards.

 
Thank you for your help, have a fabulous and productive day! I am a novice today, but someday when I accumulate enough knowledge, I can help others in my capacity.
Ksharp
Super User
Use option SHEET='.......' to get other four sheets ?
Tom
Super User Tom
Super User

You still have not said what version of SAS you are running and that might be the reason the XLSX engine is not working for you.  It is a new feature of SAS and if you are running an older version of SAS it might be only experimental and not fully functional.

 

Do process multiple sheets with IMPORT/EXPORT you need to tell it which sheet to read/write each time.

proc import datafile="C:\Users\pnguyen\Desktop\New folder\Argentina__.xlsm" out=code_list replace;
  sheet='Sheet1';
run;
proc export data=code_list outfile="C:\Users\pnguyen\Desktop\New folder\Argentina__.xlsx" dbms=xlsx replace;
  sheet='Sheet1';
run;

proc import datafile="C:\Users\pnguyen\Desktop\New folder\Argentina__.xlsm" out=code_list replace;
  sheet='Sheet2';
run;
proc export data=code_list outfile="C:\Users\pnguyen\Desktop\New folder\Argentina__.xlsx" dbms=xlsx replace;
  sheet='Sheet2';
run;

...

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 27 replies
  • 5669 views
  • 17 likes
  • 7 in conversation