BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
pspung
Fluorite | Level 6

Hi Folks, I'm trying to understand how to use libname xlsx to read a .xlsx file that does not have a header row. Ie, the first observation is on the first row. Since there's no header, I expect that the variable names will be the Excel column letters, which I can rename later. In a prior question in this community someone suggested trying header=no after the filename, such as:

LIBNAME Labs XLSX "&CourseRoot/Data/Laboratory.xlsx" header=no;

For me, that produces an error in the log: "ERROR: Libref LABS not assigned. ERROR: Error in the LIBNAME statement. ERROR 22-7: Invalid option name HEADER."

My goal is to read rows from a couple of tabs in the Excel workbook tabs into a dataset, using a data step and set statement. I've successfully done this before using libname xlsx, but the .xlsx tabs/sheets used previously had a header row.

Thanks for any suggestions, Peter

1 ACCEPTED SOLUTION

Accepted Solutions
SASKiwi
PROC Star

What happens without the HEADER option? The EXCEL engine isn't available in Unix SAS which is what you appear to be using. You could always revert to PROC IMPORT and the GETNAMES = NO option.

View solution in original post

4 REPLIES 4
Quentin
Super User

Agree, it looks like the XLSX engine does not support header=no.  

 

You could try using the older EXCEL engine, which does support that option:

LIBNAME Labs excel "&CourseRoot/Data/Laboratory.xlsx" header=no;
The Boston Area SAS Users Group is hosting free webinars!
Next up: Joe Madden & Joseph Henry present Putting Power into the Hands of the Programmer with SAS Viya Workbench on Wednesday Nov 6.
Register now at https://www.basug.org/events.
SASKiwi
PROC Star

What happens without the HEADER option? The EXCEL engine isn't available in Unix SAS which is what you appear to be using. You could always revert to PROC IMPORT and the GETNAMES = NO option.

pspung
Fluorite | Level 6

Hi SASKiwi, leaving the HEADER option off does not yield an error. However, values on the first row become variable names. Since some values repeat, eg 'R1', odd variable names are created such as R1_1, R1_2, etc.

Proc import getnames=no does indeed work as expected. I'll switch to that approach.

Thanks!  Peter

Quentin
Super User

@pspung , please mark @SASKiwi 's answer as accepted / correct, to close out this question.

The Boston Area SAS Users Group is hosting free webinars!
Next up: Joe Madden & Joseph Henry present Putting Power into the Hands of the Programmer with SAS Viya Workbench on Wednesday Nov 6.
Register now at https://www.basug.org/events.

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
  • 4 replies
  • 1009 views
  • 7 likes
  • 3 in conversation