BookmarkSubscribeRSS Feed
rykwong
Quartz | Level 8

Hi,

 

I am trying to use proc import to read in an xlsx.

I need it to not read in create any variable without a variable name in row 1.  as attached here, it created a huge number of variables on the right without header names, starting with AP, this is causing a lot of problem for me

 

many thanks 

 

4 REPLIES 4
rykwong
Quartz | Level 8

Hi,

 

I am trying to use proc import to read in an xlsx.

I need it to not read in create any variable without a variable name in row 1.  as attached here, it created a huge number of variables on the right without header names, starting with AP, this is causing a lot of problem for me

 

many thanks 

 

LinusH
Tourmaline | Level 20
Duplicate post.
Data never sleeps
LinusH
Tourmaline | Level 20
Please don't attach Excel files. A screenshot will explain the situation as good.
Data never sleeps
RW9
Diamond | Level 26 RW9
Diamond | Level 26

Excel is not a good data transfer tool, you will find many problems with it.  You have hit one of them.  Excel can have a lot of properties/hidden things on cells.  What is likely to have happened is someone has applied a format, or styling to all columns, therefore Excel assumes the working range is all columns.  Thus when SAS imports the file, it checks the working area and imports all columns specified in the working range.  To get round it, select the column aftet the last column of data, then select all rows to the right of that as well (CNTRL + Shift + Right arrow), then right click on that and select delete.

 

Alternatively, and far better (more robust, easy to re-produce, safer etc.) is to get the file in a proper data transfer file format, delimited file, XML etc.  If you got a CSV, you would then write a datastep program which specified each variable to be read in, how its to be read in, what format/length, any other processing.  Far more control and accuracy than some dodgy Excel file being read in by a guessing procedure.

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