BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
KentaMURANAKA
Pyrite | Level 9

Hi, there:

 

I am trying to load dataset from excel file, by using LIBNAME XLSX.

This excel file "TEST.xlsx" has some sheets, which are named "table 1.1-1", "table11_1", etc.

My code is below.

%let test=C:\Users\XXXXX\Desktop\XXXXXXXXXX\test.xlsx;
%put &test.;

libname test xlsx "&test" access=readonly;

data test;
    set test.table11_1;
run;

data test_;
    set test.table 1.1-1;
run;

data test_;
    set test.'table 1.1-1$'n;
run;

In library "test", there are something like SAS datasets, "TABLE 1.1-1" & "TABLE11_1".

In library "work", I can find SAS dataset "test" with no errors & warnings.

But I cannot find "test_" from spreadsheet "table 1.1-1" and SAS says "Syntax error, expecting one of the following ~" or "Couldn't find range or sheet in spreadsheet".

 

I know SAS usually does not allow hypen or blank as data names.

I would like to use data in sheet "table 1.1-1" using LIBNAME XLSX.

 

Any advice is welcome.

Thank you in advance.

 

 

1 ACCEPTED SOLUTION
3 REPLIES 3
KentaMURANAKA
Pyrite | Level 9

Hi, Kurt-san:

 

Thank you for your advice.

Now, I can load "table 1.1-1" data.

 

Thank you!!

ballardw
Super User

Please do not make us guess where an error occurs.

When you get an error copy from the log the entire data step or procedure that generates the error along with the text of any notes, messages and the errors. Then paste all that copied text into a code box opened on the forum using the </> icon. The code box is important to preserve formatting of the text and any diagnostic characters that SAS often provides as the main message window will reformat text making those aids less useful.

 

You may also need to have the option VALIDMEMNAME=extend set to deal with non-standard characters for SAS datasets in the sheet names.

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 3 replies
  • 813 views
  • 1 like
  • 3 in conversation