Learning SAS? Welcome to the exclusive online community for all SAS learners.

Importing range of a xlsx file into SAS University Edition

Reply
New Contributor
Posts: 2

Importing range of a xlsx file into SAS University Edition

[ Edited ]

Hey everyone,

 

I'm having trouble importing an excel file. I can import the full excel file perfectly fine, but when I want to import just a specific range within it, I'm running into errors and it won't import. Here's my code:

 

PROC IMPORT OUT=WORK.name
DATAFILE="/folders/myfolders/foldername/filename.xlsx"
DBMS=XLSX REPLACE;
RANGE="C6:S251";
RUN;

 

I'm using SAS University Edition.

 

Thanks!

Super User
Posts: 17,829

Re: Importing range of a xlsx file into SAS University Edition

Try specifying a sheet as well. Though I'm not sure XLSX supports ranges 

New Contributor
Posts: 2

Re: Importing range of a xlsx file into SAS University Edition

[ Edited ]

Reeza,

 

Do you have any recommendations then? I need to get a specific range.

 

Thanks!

 

EDIT: I tried adding the sheet suggestion. It just imported the whole thing again.

Super User
Posts: 17,829

Re: Importing range of a xlsx file into SAS University Edition

Two other possibilities 

Dbms=excel

 

or create a named range in excel and then use libname method. 

 

If if no one posts a concrete solution I'll give it a look later tonight in detail. 

Super User
Posts: 17,829

Re: Importing range of a xlsx file into SAS University Edition

I couldn't find a way using SAS UE Smiley Sad

 

You can using a full SAS installation though. 

Super User
Posts: 9,681

Re: Importing range of a xlsx file into SAS University Edition

I can import it , no problem.



PROC IMPORT OUT=WORK.name
DATAFILE="/folders/myfolders/have.xlsx"
DBMS=XLSX REPLACE;
RANGE="Sheet1$C6:E20";
RUN;


Super User
Posts: 17,829

Re: Importing range of a xlsx file into SAS University Edition

Weird. I tried that. No error but the dataset isn't correct. 

Ask a Question
Discussion stats
  • 6 replies
  • 367 views
  • 0 likes
  • 3 in conversation