Using external mod file

Hello,
Can I use an external mod file where i save the variables, exogenous variables, parameters etc to my main mod file using reference to this external mod file?
For example, Say I have main.mod file. I also have a mod file called preamble.mod where I save all information regarding the model.
Now how do I declare these information in the main mod file?

See

Excellent solution. Thanks

I still could not figure this completely.

does this work?

var @#include “params.mod”

varexo @#include “params.mod”

?

What exactly do you want to do? Why would you include the same text file twice?

I have an external mod file where i save information regarding model like below (which i call params.mod)

%%%% endogenous variables %%%
var y_t \hat{y} % 1 => output
c_t \hat{c} % 2 => consumption
i_t \hat{i} % 3 => investment
k_t \hat{k} % 4 => effective capital

%%% shock processes %%%
z_t \hat{z} % 17 => technology shocks process
ztil_t \hat{\tilde{z}} % 18 => technology shocks process
b_t \hat{b}

etc

Now I have a main mod file where I write the model equations (main.mod)

How can I use the information from params.mod into main.mod? I mean don’t i have to declare variables in the main.mod? if yes, how? or is it enough to just add the params.mod file completely with @#include macro?

The macro processor does text operations. You can use the savemacro-option to see the result. You could have a mod-file composed only of @#include-statements. The included files simply need to contain all the Dynare codes

but how does the main mod file understand this?

The main file does not need to understand anything, because the “main”-file that will be run is the one constructed from including everything. Simply check out the results from the savemacro option to see this new “main”-file.