Please enable JavaScript to view this site.

Vensim Help

A fairly common way to store output is likely to be by scenario.  The following will store both values over time and values at a time (or constants) to tables which have a scenario identifier.  The DELETE command is used to overwrite the existing scenario results with the same scenario name.  In all cases we use the simulation run name as the scenario name.

:CONNECT DATA1

:VARLOOKUP

:VARID=ID

:VARNAME=Varname

:SUB=sub1

:SELECT VARIABLES

:DATA

:FIELD scenario=!

:EXECUTE DELETE FROM DATA_OUTPUT

:VARLIST

variable one

variable two

:TIME X

:VALUE Y

:VARID VARID

:FIELD SCENARIO=!

:INSERT DATA_OUTPUT

:CONSTANT

:FIELD scenario=!

:EXECUTE DELETE FROM CONSTANT_OUTPUT

:VARLIST

constant one

constant two

:TIME X

:VALUE Y

:VARID VARID

:FIELD SCENARIO=!

:INSERT CONSTANT_OUTPUT

 

Note that the DELETE command is constrained by the :FIELD value so that if the run name is current it would become

DELETE FROM DATA_OUTPUT WHERE SCENARIO=’current’

This SQL statement clears out the old results with the same scenario name.  The Data and Constants are output to two different tables.  

If a Constant were output in the :DATA section its value would be output once at the first simulation time.  Conversely, if a dynamic variable were to be output in the :CONSTANT section its value would be the final value unless you included a :TIME #other statement to specify which time to fetch values from.