Retrieving data of particular year only

Use this forum to post Vensim related questions.
Post Reply
nahsan
Junior Member
Posts: 7
Joined: Mon Mar 27, 2023 2:47 pm
Vensim version: PLE+

Retrieving data of particular year only

Post by nahsan »

I need help that I want to retrieve only data of one particular year from stock of 100 years. Lookup functions needs two data sets but what if i just know the year but not the stock in that year. How Vensim can get only one value from stock of 100 years? Thank you
tomfid
Administrator
Posts: 3986
Joined: Wed May 24, 2006 4:54 am

Re: Retrieving data of particular year only

Post by tomfid »

Not sure I understand the question. If you don't know the stock values, how will you retrieve one?

If you have time series data, you can use GET DATA AT TIME or GET DATA BETWEEN TIMES. These functions tend to be slow, so often it's good to wrap them in an INITIAL().
nahsan
Junior Member
Posts: 7
Joined: Mon Mar 27, 2023 2:47 pm
Vensim version: PLE+

Re: Retrieving data of particular year only

Post by nahsan »

Indeed my question was not clear. for example my model calculated the stock over period of 50 years (2000-2050). Now from this calculation I want to know the stock at one particular year lets say 2015. How Can i get this value? I tried to do by using GET DATA AT TIME but my vensim says it is not supported.
tomfid
Administrator
Posts: 3986
Joined: Wed May 24, 2006 4:54 am

Re: Retrieving data of particular year only

Post by tomfid »

Ah - you can use SAMPLE IF TRUE for that.

If you don't have it (PLE), you can use a stock to freeze the value. Something like:

value = ... { your stock } ~ stuff
sampled value = INTEG( sample adj rate, value ) ~ stuff
sample adj rate = IF THEN ELSE(time<=sample time,(value-sampled value)/TIME STEP,0) ~ stuff/time
sample time = 2015 ~ time

There's a lag of one time step in reporting the 2015 value, though that can be corrected if needed.
Post Reply