BookmarkSubscribeRSS Feed
FRAFLUTE
Calcite | Level 5

Hi, i want to use SAS to run a macro in a excel .xlsm file. I read this useful guide:

 

https://blogs.sas.com/content/sasdummy/2011/05/03/using-sas-enterprise-guide-to-run-programs-in-batc...

 

but i've a problem to use the filename "excel|system" option.

The code is:

options noxwait noxsync;
x '"C:\Program Files (x86)\Microsoft Office\Office14\EXCEL.EXE" ';
/* Sleep for 5 seconds to give Excel time to come up */
data _null_;
x=sleep(5);
run;
filename cmds dde "excel|system";

data _null_;
file cmds;
/* Open the excel file test.xlsm which contains the VBA macro */
put '[open("X:\temp\test.xlsm")]';
/* Run myVBAmacro */
put '[run("test.xlsm!myVBAmacro")]';
run;

When i run a program the log give back this error:

 

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

 

What is wrong?

 

Thanks for the support

5 REPLIES 5
Reeza
Super User
First verify that XCMD is enabled and that you're not running on a server. If you are, DDE isn't a process that will work for you.

You can verify your XCMD option using hte following:

proc options option=xcmd;run;
FRAFLUTE
Calcite | Level 5

Thank you for the reply!

I didn't understand the log from the code submitted for XCMD... 😞

The log is:

NOTE: Writing TAGSETS.SASREPORT13(EGSR) Body file: EGSR
21         
22         GOPTIONS ACCESSIBLE;
23         proc options
24         option=xcmd;
25         run;

    SAS (r) Proprietary Software Release 9.4  TS1M2

 XCMD              Enables the X command in SAS.
NOTE: PROCEDURE OPTIONS used (Total process time):
      real time           0.00 seconds
      cpu time            0.00 seconds
      

26         
27         GOPTIONS NOACCESSIBLE;
28         %LET _CLIENTTASKLABEL=;
29         %LET _CLIENTPROJECTPATH=;
30         %LET _CLIENTPROJECTNAME=;
31         %LET _SASPROGRAMFILE=;
32         
33         ;*';*";*/;quit;run;
34         ODS _ALL_ CLOSE;
35         
36         
37         QUIT; RUN;

it's enable?

 

Sorry!

Reeza
Super User
Yes it is. The second thing is to check that SAS runs locally or server and then if it runs locally, verify that your path to Excel is correct. It changes for each version of Excel.
FRAFLUTE
Calcite | Level 5

Probably SAS run on server, because for starting the process we wait the connection to the server SAS App. It's possible?

 

Sorry for my ignorance and thank you for your support!

Reeza
Super User
SAS needs to have access to the file and Excel, whether that's on a server or locally. You need to ensure you have both in the same place. If you don't you cannot do this. Some indications you may not be able to - you have to manually download the file from the server to work with it, you can't import files from your desktop using code.

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
SAS Enterprise Guide vs. SAS Studio

What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.

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
  • 5 replies
  • 6192 views
  • 0 likes
  • 2 in conversation