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
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.
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.
Ready to level-up your skills? Choose your own adventure.