Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to run a SAS program using VBA?

Status
Not open for further replies.

riskassure

Programmer
May 6, 2005
33
US
Hi,

I am trying to write a program using VBA in Excel to run a SAS program (a .sas file). Does anyone know how this can be accomplished?

Thanks in advance!

~~CW~~
 
This can be done, but in my opinion it is much easier to use DDE commands to launch excel, call the excel macro within SAS do all you coding for the excel in the VBA code, have SAS quit excel after the VBA macro is done, and launch SAS using batch files.

You can use digital signatures in Excel so it doesn't prompt you if the macro is trusted.

I have code if you are interested, but do not have it handy at the moment.
 
Sorry for not replying sooner:

Code to open excel and call excel macros using DDE.

Code:
options noxwait noxsync; run;
x '"C:\Program Files\Microsoft Office\Office11\EXCEL.EXE"';
                  

data _null_;
     x=sleep(5);
run;

FileName cmds dde 'excel|system'; Run;

DATA _NULL_;
     File cmds;
     Put '[OPEN("C:\excel.xls")]';
     X=SLEEP(5);
RUN;

Data _Null_;
     File cmds;
     Put '[RUN("RUN_REPORT")]';
Run;

Data _Null_;
     File cmds;
     Put '[RUN("SAVE_REPORT")]';
Run;

Data _Null_;
     file cmds;
     put '[QUIT()]';
run;
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top