DATA Step, Macro, Functions and more

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

Reply
Contributor
Posts: 36

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

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 

 

Contributor
Posts: 36

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

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 

 

Super User
Posts: 5,255

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

Duplicate post.
Data never sleeps
Super User
Posts: 5,255

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

Please don't attach Excel files. A screenshot will explain the situation as good.
Data never sleeps
Super User
Super User
Posts: 7,392

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

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.

Ask a Question
Discussion stats
  • 4 replies
  • 398 views
  • 0 likes
  • 3 in conversation