Calling Vensim from SAS via DDE?

Use this forum to post Vensim related questions.
Post Reply
guneralp
Junior Member
Posts: 2
Joined: Tue May 23, 2006 5:33 pm

Calling Vensim from SAS via DDE?

Post by guneralp »

Greetings!
I need to couple Vensim and SAS. Since SAS only acts as a client I tried to call Vensim directly from SAS via DDE. For some reason, Vensim does not respond to the comments that I pass to it. There is no error message from SAS. It looks like it does its job of passing the commands. The lines of code I use and the log from SAS are below this note. Could you help me getting this work? This is supposed to be very straightforward; either I am missing a simple point or maybe Vensim is not compatible with SAS?

Thank you in advance,

options noxwait noxsync;
x '"C:\Program Files\Vensim\Vensimdp.exe"';
filename tst dde 'vensim|system';
data _null_;
file tst;
put '[SPECIAL>LOADMODEL|C:\Intro.vmf]';
put '[SIMULATE>RUNNAME|C:\bob1]';
put '[MENU>RUN|O]';
put '[MENU>EXIT]';
run;

The log:
22 options noxwait noxsync;

23 x '"C:\Program Files\Vensim\Vensim.exe"'

23 ! ;

24 data _nll_;

25 x=sleep(10);

26 run;



NOTE: The data set WORK._NLL_ has 1 observations and 1 variables.

NOTE: DATA statement used (Total process time):

real time 10.01 seconds

cpu time 0.03 seconds


27 filename tsst dde 'vensim|system' command;

28 data _null_;

29 file tsst;

30 put '[SPECIAL>LOADMODEL|C:\Intro.vmf]';

31 run;



NOTE: The file TSST is:

DDE Session,

SESSION=vensim|system,RECFM=V,LRECL=256



NOTE: 1 record was written to the file TSST.

The minimum record length was 32.

The maximum record length was 32.

NOTE: DATA statement used (Total process time):

real time 0.01 seconds

cpu time 0.01 seconds
Administrator
Super Administrator
Posts: 4838
Joined: Wed Mar 05, 2003 3:10 am

Post by Administrator »

There is no reason why it should not work as long as SAS is passing the DDE commands correctly.

The line
x '"C:\Program Files\Vensim\Vensimdp.exe"';

Does that run Vensim? If so, try starting Vensim before executing the SAS code. Maybe the code runs before Vensim has started up properly.

Tony.
bob@vensim.com
Senior Member
Posts: 1107
Joined: Wed Mar 12, 2003 2:46 pm

Post by bob@vensim.com »

I also notice there is s vensimdp.exe in one place and a vensim.exe with no dp in another and that may be a source of confusion.

Generally DDE is not very reliable so if you can reconfigure your application to call the Vensim DLL that may work better.
guneralp
Junior Member
Posts: 2
Joined: Tue May 23, 2006 5:33 pm

Post by guneralp »

Thanks for the replies... Unfortunately, before posting my inquiry, I had already made sure that Vensim started properly before executing the rest of the code. I had also tried running vensim.exe instead of vensimdp.exe. So none of them can be the reason for not being able to get this running.

I tried calling Vensim DLL today as Bob suggested using the data step below:
data _null_;
CALL MODULE('VdpDLL32,vensim_command',"SPECIAL>LOADMODEL|C:\Research\Intro.vmf");
run;

This time I get an error message from SAS:
ERROR: Write Access Violation In Task [ DATASTEP )
Exception occurred at (02067820)
Task Traceback
Address Frame (DBGHELP API Version 4.0 rev 5)

I am not sure if this genuinely originates from SAS or due to Vensim...

Anyway, I will continue trying to get this Vensim-SAS connection to work either thru DDE or DLL. I would appreciate any pointers along the way...

Thank you...

Burak
Administrator
Super Administrator
Posts: 4838
Joined: Wed Mar 05, 2003 3:10 am

Post by Administrator »

Just to check the obvious, but is VdpDLL32.DLL in your c:\windows\system32 directory?
bob@vensim.com
Senior Member
Posts: 1107
Joined: Wed Mar 12, 2003 2:46 pm

Post by bob@vensim.com »

I can't help but notice that the CALL MODULE syntax has mismatched quotes I would expect something more like

CALL MODULE("VdpDLL32","vensim_command","SPECIAL>LOADMODEL|C:\Research\Intro.vmf");

or perhaps using single quotes throughout (or maybe they are interchangeable?)
Post Reply