BookmarkSubscribeRSS Feed
frupaul
Quartz | Level 8

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,

1 REPLY 1
Kurt_Bremser
Super User

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.

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

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
  • 1 reply
  • 1838 views
  • 0 likes
  • 2 in conversation