DATA Step, Macro, Functions and more

How to use PROC IMPORT on Excel worksheet whose name begins with a space

Accepted Solution Solved
Reply
Trusted Advisor
Posts: 1,631
Accepted Solution

How to use PROC IMPORT on Excel worksheet whose name begins with a space

The name of the worksheet I would like to import into Excel begins with a space, it actually has two spaces, the name is

' AUTOBOND2 RAW' but there are no quotes in the name, I just put them there so you can see the initial space. But when I try

proc import datafile="myfile.xlsx" out=AUTOBOND2 dbms=excel replace;

  sheet=" AUTOBOND2 RAW";

  run;

Produces the error in the LOG

ERROR: Prepare: Invalid bracketing of name ' AUTOBOND2 RAW$'.

SQL statement: SELECT * FROM ` AUTOBOND2 RAW$`

ERROR: Import unsuccessful.  See SAS Log for details.

How do I read this worksheet?


Accepted Solutions
Solution
‎05-16-2015 03:38 AM
Super User
Posts: 9,691

Re: How to use PROC IMPORT on Excel worksheet whose name begins with a space

sheet=" AUTOBOND2 RAW$"n ;


OR Try libname statement , my favorite .





Xia Keshan

View solution in original post


All Replies
Solution
‎05-16-2015 03:38 AM
Super User
Posts: 9,691

Re: How to use PROC IMPORT on Excel worksheet whose name begins with a space

sheet=" AUTOBOND2 RAW$"n ;


OR Try libname statement , my favorite .





Xia Keshan

Trusted Advisor
Posts: 1,631

Re: How to use PROC IMPORT on Excel worksheet whose name begins with a space

sheet=" AUTOBOND2 RAW$"n ;

Does not work, same error message

Try libname statement , my favorite .

This works. Thanks!

Super User
Posts: 9,691

Re: How to use PROC IMPORT on Excel worksheet whose name begins with a space

You can open that libname to see what exactly table name it is .

Maybe it like " AUTOBOND2 RAW                            $"n

Trusted Advisor
Posts: 1,631

Re: How to use PROC IMPORT on Excel worksheet whose name begins with a space

No, it shows as " AUTOBOND2 RAW$" with no trailing spaces.

Nevertheless, I think the problem has been solved by usingthe libname statement.

🔒 This topic is solved and locked.

Need further help from the community? Please ask a new question.

Discussion stats
  • 4 replies
  • 427 views
  • 1 like
  • 2 in conversation