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.

 

hackathon24-white-horiz.png

The 2025 SAS Hackathon Kicks Off on June 11!

Watch the live Hackathon Kickoff to get all the essential information about the SAS Hackathon—including how to join, how to participate, and expert tips for success.

YouTube LinkedIn

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 17 replies
  • 99416 views
  • 5 likes
  • 10 in conversation