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-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

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
  • 91419 views
  • 4 likes
  • 10 in conversation