How do you run some SAS code while using VB?
|
Provided you only want to run a simple program that would normally run in the SAS Program Editor, you can use VB and DDE, like in the following VB code, to simulate the typing of a SAS programmer, e.g.:
rc = Shell("c:\sas\sas.exe", vbMaximizedFocus) 'start SAS in maximized window
For i = 1 to 1000 'wait for SAS to initialize
DoEvents()
Next i
SendKeys "%GP", True 'Globals, Program Editor
SendKeys "{%}let macrovar = 1234;~", True 'set SAS macro variable
SendKeys "dm 'af c=lib.cat.prog.frame' af;~", True 'run AF application
SendKeys "%LS" 'Locals, Submit
SendKeys "%GP", True 'Globals, Program Editor
SendKeys "endsas;~", True 'Exit SAS
SendKeys "%LS" 'Locals, Submit
This is the same as starting a SAS session, typing the following Base SAS code in the Program Editor, submitting the SAS code, which also ends the SAS session after the AF Frame application has completed:
%let macrovar = 1234;
dm 'af c=lib.cat.prog.frame' af;
endsas;
|