How to get SAS to read excel column headers in row 2

Reply
Contributor
Posts: 73

How to get SAS to read excel column headers in row 2

Hi everyone,

 

I am trying to read in an excel file (attached) into SAS with column headers starting in row 2. My objective is to get SAS to recognise that column names are in row 2 and therefore pick these up as column names.

 

What I have written so far is:

 

options validvarname=v7; 
libname contact xlsx '/home/frupaul0/Lucamod/Contact.xlsx';

 

proc print data=contact.contact_info;
run;

 

And what I get from this is (partial output):

Screen Shot 2018-07-20 at 07.27.34.png

So SAS has considered the column headers in row to to be variable values.

 

Can anyone help please?

 

Thanks,

Super User
Posts: 10,589

Re: How to get SAS to read excel column headers in row 2

Export to csv from Excel and read with a custom data step, or remove the first line in Excel.

Both libname xlsx and proc import do not support variable names in a line other than the first.

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
How to convert datasets to data steps
How to post code
Ask a Question
Discussion stats
  • 1 reply
  • 46 views
  • 0 likes
  • 2 in conversation