Automatize specifying a sequence of exogenous shocks

Dear all,

I am trying to compute a perfect foresight solution where I specify the values of a variable the following way

shocks;
var A;
periods 1 2 3 4;
values 1 2 3 4;
end;

This works smoothly.
Now I would like to automatize the specification of values (which in turn I read in from a matrix).
First I thought, I can use the eval, like:

eval('values 1 2 3 4;')

instead of

values 1 2 3 4;

where I created a string ‘values 1 2 3 4;’.
However, this produces an error.
Then I tried to put the whole shocks block in a string and then use eval, like:

shock_string='shocks; var A; periods 1 2 3 4; values 1 2 3 4; end;'
eval(shock_string)

but this also failed, with the message: “Error: Illegal use of reserved keyword “end””.
Is there a good way of specifying the sequence of exogenous variables automatically?
Thank you very much and many greetings

Have a look at Section 4.8 Shocks on exogenous variables of the Dynare manual. There is an “Example (with vector values)”.

Dear Professor Pfeifer,

this is perfect, thank you very much!
I apologize for not finding this solution by myself.

Thank you very much and many greetings