Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SAS - proc import excel - first sheet

Tags:

sas

Is there a way to import the first sheet from an excel file, without specifying the name of the sheet.

PROC IMPORT  
  DATAFILE= "filePath\fileName.xlsx" 
  DBMS=EXCEL REPLACE
  OUT= _fileName_OUT.;
  SHEET = 'sheetName';
  GETNAMES=YES;
  MIXED=NO;
  SCANTEXT=YES;
  USEDATE=YES;
  SCANTIME=YES;
RUN;

So instead of using the "sheetName" parameter, I am looking for a generic term that would specify that it should be the first sheet in the excel file.

like image 305
janez_007 Avatar asked Jan 16 '26 19:01

janez_007


1 Answers

SAS automatically imports the "first" sheet in the excel file, for a certain definition of first, if you don't use the sheet statement. So if you simply proc import the file without specifying sheet, you'll get whatever the first is. But it won't be necessarily the left-most; it's the first in Excel's internal thinking.

Also, the dbms you use matters. EXCEL and XLSX do different things. EXCEL seems to take the original SHEET1; XLSX seems to take the left most sheet, by default.

like image 114
Joe Avatar answered Jan 19 '26 19:01

Joe



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!