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: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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