BookmarkSubscribeRSS Feed
juju_p
Obsidian | Level 7

Dear all,

 

I am experiencing an issue with the following statement to open an Excel file with SAS 9.4

I do not understand why SAS says that the physical file does not exist although it is well there

 

CODE

options noxwait noxsync;
x '"C:\Program Files (x86)\Microsoft Office\root\Office16\EXCEL.EXE"';
data _null_;
x=sleep(5);
run;

/* Open Excel workbook automatically */
filename ddecmd dde 'excel|system';
DATA _null_;
file ddecmd;

/* Adapt Path and name of the input excel file */
put '[OPEN("S:\TRIALS\AES\AES1\DBASE\DBASE_EXT\ADA\FU_PERIOD\TROIKA_ADA_FU_22Jan2022_bis.xlsx")]';
RUN;

/* Adapt Path and name of the input excel file */
filename file dde 'excel|S:\TRIALS\AES\AES1\DBASE\DBASE_EXT\ADA\FU_PERIOD\[TROIKA_ADA_FU_22Jan2022_bis.xlsx]DTAformat!R2C1:R1000C13' lrecl=500;

/*Create SAS dataset for external data*/

 

DATA ada;
INFILE file dlm='09'x notab dsd missover ls=1500;
informat PROTOCOL $6. AGILEX $3. SUBJID $11. BARCODE $11. VISITT $20. BIOMATRIX $9. ANLYTE $16. SCROUT $8. CONFOUT $8. TITROUT 3. RESCO $10. ;
input PROTOCOL $ AGILEX $ SUBJID $ BARCODE $ VISITT $ BIOMATRIX $ ANLYTE $ SCROUT $ CONFOUT $ TITROUT RESCO $ ;
/* IF visitt = 'FU 1 Year' then visitt='1 Year FU';*/
RUN;

 

 

ERROR MESSAGE

ERROR: Physical file does not exist,
excel|S:\TRIALS\AES\AES1\DBASE\DBASE_EXT\ADA\FU_PERIOD\[TROIKA_ADA_FU_22Jan2022_bis.xlsx]DTAformat!R2C1
:R1000C13.

5 REPLIES 5
LinusH
Tourmaline | Level 20

Can't tell why this does not work for you, but DDE is discontinued technology.

If your task is to import Excel data to SAS, I suggest that you use any of the many other methods to do so.

Data never sleeps
Kurt_Bremser
Super User

Since DDE is deprecated and may not work any longer, I'd use VBA to load the spreadsheet and save it to a tab-separated file, which can then be read as a physical file in the data step.

juju_p
Obsidian | Level 7

It happened to work for me when I copied the whole content of the file into another file so it probably has to do with the properties of the original file

 

I was wondering how could we do it as well with VBA?

Kurt_Bremser
Super User

@juju_p wrote:

 

I was wondering how could we do it as well with VBA?


That needs to be answered by some Windows-savvy people. I neither use Excel files, nor run SAS on Windows 😉

AMSAS
SAS Super FREQ

There are multiple ways to read Excel files into SAS e.g. Comparing SAS LIBNAME Engines for PC Files Data 

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

Mastering the WHERE Clause in PROC SQL

SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 5 replies
  • 584 views
  • 1 like
  • 4 in conversation