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 (BASUG) is hosting our in person SAS Blowout on Oct 18!
This full-day event in Cambridge, Mass features four presenters from SAS, presenting on a range of SAS 9 programming topics. Pre-registration by Oct 15 is required.
Full details and registration info 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 (BASUG) is hosting our in person SAS Blowout on Oct 18!
This full-day event in Cambridge, Mass features four presenters from SAS, presenting on a range of SAS 9 programming topics. Pre-registration by Oct 15 is required.
Full details and registration info at https://www.basug.org/events.

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