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

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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
  • 1118 views
  • 0 likes
  • 3 in conversation