# Using external mod file

**URL:** <https://forum.dynare.org/t/using-external-mod-file/18366>\
**Category:** Macro-language\
**Created:** [21 June 2021 10:04 UTC](https://forum.dynare.org/t/using-external-mod-file/18366 "2021-06-21T10:04:40Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![nithinmkp](https://forum.dynare.org/letter_avatar_proxy/v4/letter/n/e9a140/32.png) [@nithinmkp](https://forum.dynare.org/u/nithinmkp)\
**Post date:** [21 June 2021 10:04 UTC](https://forum.dynare.org/t/using-external-mod-file/18366/1 "2021-06-21T10:04:40Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![jpfeifer](https://forum.dynare.org/user_avatar/forum.dynare.org/jpfeifer/32/5044_2.png) [@jpfeifer](https://forum.dynare.org/u/jpfeifer)\
**Post date:** [21 June 2021 12:08 UTC](https://forum.dynare.org/t/using-external-mod-file/18366/2 "2021-06-21T12:08:43Z")

</div>

See

> [@Including code withing a .mod file](https://forum.dynare.org/t/including-code-withing-a-mod-file/2170/2):
>
> Yes, use the “@#include” directive of the macro-processor. Have a look at the “macroprocessor.pdf” file or to the reference manual (both in the documentation directory of Dynare).

---

<div class="post-metadata">

**Author:** ![nithinmkp](https://forum.dynare.org/letter_avatar_proxy/v4/letter/n/e9a140/32.png) [@nithinmkp](https://forum.dynare.org/u/nithinmkp)\
**Post date:** [21 June 2021 14:20 UTC](https://forum.dynare.org/t/using-external-mod-file/18366/3 "2021-06-21T14:20:18Z")

</div>

Excellent solution. Thanks

---

<div class="post-metadata">

**Author:** ![nithinmkp](https://forum.dynare.org/letter_avatar_proxy/v4/letter/n/e9a140/32.png) [@nithinmkp](https://forum.dynare.org/u/nithinmkp)\
**Post date:** [22 June 2021 17:52 UTC](https://forum.dynare.org/t/using-external-mod-file/18366/4 "2021-06-22T17:52:42Z")

</div>

I still could not figure this completely.

does this work?

var @#include “params.mod”

varexo @#include “params.mod”

?

---

<div class="post-metadata">

**Author:** ![jpfeifer](https://forum.dynare.org/user_avatar/forum.dynare.org/jpfeifer/32/5044_2.png) [@jpfeifer](https://forum.dynare.org/u/jpfeifer)\
**Post date:** [23 June 2021 11:25 UTC](https://forum.dynare.org/t/using-external-mod-file/18366/5 "2021-06-23T11:25:43Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![nithinmkp](https://forum.dynare.org/letter_avatar_proxy/v4/letter/n/e9a140/32.png) [@nithinmkp](https://forum.dynare.org/u/nithinmkp)\
**Post date:** [23 June 2021 13:31 UTC](https://forum.dynare.org/t/using-external-mod-file/18366/6 "2021-06-23T13:31:21Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![jpfeifer](https://forum.dynare.org/user_avatar/forum.dynare.org/jpfeifer/32/5044_2.png) [@jpfeifer](https://forum.dynare.org/u/jpfeifer)\
**Post date:** [24 June 2021 19:33 UTC](https://forum.dynare.org/t/using-external-mod-file/18366/7 "2021-06-24T19:33:40Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![nithinmkp](https://forum.dynare.org/letter_avatar_proxy/v4/letter/n/e9a140/32.png) [@nithinmkp](https://forum.dynare.org/u/nithinmkp)\
**Post date:** [25 June 2021 19:03 UTC](https://forum.dynare.org/t/using-external-mod-file/18366/8 "2021-06-25T19:03:48Z")

</div>

but how does the main mod file understand this?

---

<div class="post-metadata">

**Author:** ![jpfeifer](https://forum.dynare.org/user_avatar/forum.dynare.org/jpfeifer/32/5044_2.png) [@jpfeifer](https://forum.dynare.org/u/jpfeifer)\
**Post date:** [25 June 2021 19:22 UTC](https://forum.dynare.org/t/using-external-mod-file/18366/9 "2021-06-25T19:22:10Z")

</div>

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.
