BookmarkSubscribeRSS Feed
rinsabraham
Obsidian | Level 7

Hello,

 

I'm running as DDE sas code to read data  from a SAS dataset into a structured Excel Template.the template file opens in Excel so I know this part is working (and it does the same thing in the working program), but for some reason when it gets to the write in data step, it doesn't seem to notice the excel file exists.when i execute the same code second time then code will execute successfully

 

ERROR: Physical file does not exist, excel|system.

 

code:

Options noxwait noxsync ;

x '"C:\Program Files\Microsoft Office\Office\EXCEL.EXE"' ;
Data _null_ ;
rc = sleep(3);
Run ;

/* save blank spreadsheet to desired location */
Filename msEXL dde 'excel|system' lrecl=2048;

data _null_;
infile = "&infile_name.";
outfile = "&file_path.&outfile_name.";

filein = '[FILE-OPEN("' || infile || '")]';
/*run;*/
fileout = '[SAVE.AS("' || outfile || '")]';

call symput('open_file', outfile);

file msEXL ;
put '[error(false)]';
put filein;
put fileout;
Run ;

 

Log:

1356 /* save blank spreadsheet to desired location */
1357 Filename msEXL dde 'excel|system' lrecl=2048;
1358
1359 data _null_;
1360 infile = "&infile_name.";
1361 outfile = "&file_path.&outfile_name.";
1362
33 The SAS System

1363 filein = '[FILE-OPEN("' || infile || '")]';
1364 /*run;*/
1365 fileout = '[SAVE.AS("' || outfile || '")]';
1366
1367 call symput('open_file', outfile);
1368
1369 file msEXL ;
1370 put '[error(false)]';
1371 put filein;
1372 put fileout;
1373 Run ;

ERROR: Physical file does not exist, excel|system.
NOTE: The SAS System stopped processing this step because of errors.

 

Can you please help me

2 REPLIES 2
ballardw
Super User

First thing is  no double check that the path for your EXCEL.EXE is as you show. I suspect not as the last few iterations have had a folder named Office13 or Office14 or ...

If the Excel does not start then you can't get a dde connection and will return that error.

 

Also, DDE is so fragile and basically not supported any more. I would strongly suggest examining why you think you need DDE to begin with. Also there are other programs that will interfere with DDE attempts just by running.

 

Cisco Jabber is one. So if you have that application you have to kill it, not just the application window the service process as well before DDE will have a chance of working.

Reeza
Super User
I don't see anything in your code that would write to an Excel file ever. Your code shows an open and a SAVE AS but has no SET statement and no PUT statements indicating it's writing to the file.
And your log seems to indicate that the connection to Excel did not succeed so I'm surprised your template even opened. I'm guessing this isn't the code you're actually running.

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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
  • 2 replies
  • 2469 views
  • 2 likes
  • 3 in conversation