BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
gboor
Calcite | Level 5

Maybe it is due to the typo?

I see a .xlxs extension, which should be a .xlsx extension...

msteelman
Calcite | Level 5

I use this for code for xls and xlsx files

&prjdir is a macro for the file path.

&file1 and &sheet1 are macros for the file name and sheet name you want to read

 

filename case DDE "Excel|&prjdir.[&file1.]&sheet2.!R<first row>C<first column>:R<last row>C<last column>" notab;
data want;
infile case dsd dlm='09'x missover pad lrecl=1500;
length <vars with lengths>;
input <vars>;
run;
filename case clear;

 

So a filled in example.

 

%LET prjdir=C:\Desktop\WR213548\;

%LET file1=test;

%LET sheet1=sheet1;

filename case DDE "Excel|&prjdir.[&file1.]&sheet2.!R1C1:R1000C25" notab; *1000 rows 25 columns;
data want;
infile case dsd dlm='09'x missover pad lrecl=1500; *change lrecl to fit your full row length;
length var1-var25 $20.;
input var1-var25;
run;
filename case clear;

 

Edit as needed.  Make sure that you have your excel file open and enabled editing before running this or you'll get an error.

 

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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
  • 17 replies
  • 94962 views
  • 5 likes
  • 10 in conversation