# Macro-language

**URL:** https://forum.dynare.org/c/macrolanguage/23.md

[Latest](https://forum.dynare.org/latest.md) · [Categories](https://forum.dynare.org/categories.md)

---

## [About the Macro-language category](https://forum.dynare.org/t/about-the-macro-language-category/10473)

<div class="topic-metadata">

**Author:** [@jpfeifer](https://forum.dynare.org/u/jpfeifer)\
**Replies:** 0

</div>

Questions related to Dynare’s macro language

---

## [Macroprocessing language loop through equations](https://forum.dynare.org/t/macroprocessing-language-loop-through-equations/28097)

<div class="topic-metadata">

**Author:** [@kurama](https://forum.dynare.org/u/kurama)\
**Replies:** 3\
**Last updated:** [18 November 2025 15:32 UTC](https://forum.dynare.org/t/macroprocessing-language-loop-through-equations/28097 "2025-11-18T15:32:27Z")

</div>

Hello, can I do something like this in mod file? @#for eq\_name in equation\_list @#for dummy\_var in covid\_varnames equation\[@eq\_name\] +@eq\_name{RHS}\_@{dummy\_var} \* @{dummy\_var} @#endfor @#endfor

---

## [Questions about Macro Language Related to Vectors](https://forum.dynare.org/t/questions-about-macro-language-related-to-vectors/27343)

<div class="topic-metadata">

**Author:** [@KASD](https://forum.dynare.org/u/KASD)\
**Replies:** 3\
**Last updated:** [30 March 2025 14:19 UTC](https://forum.dynare.org/t/questions-about-macro-language-related-to-vectors/27343 "2025-03-30T14:19:56Z")

</div>

Hello everyone, I’m currently facing a few issues when using macro-language in Dynare. I would appreciate any help or insights! 1. How to Access Elements in a MATLAB Vector Using Macro Language? I tried to extract an e…

---

## [Macroprocessor questions for 6.3](https://forum.dynare.org/t/macroprocessor-questions-for-6-3/27310)

<div class="topic-metadata">

**Author:** [@pts91](https://forum.dynare.org/u/pts91)\
**Replies:** 1\
**Last updated:** [14 March 2025 07:25 UTC](https://forum.dynare.org/t/macroprocessor-questions-for-6-3/27310 "2025-03-14T07:25:07Z")

</div>

Hello, I am trying for Macroprocessor in Dynare 6.3, the setup works fine with dynare 4.4.3, however, it doesn’t work with dynare 6.3. I wonder if there has been any update on this feature? I upload my files, my problem…

---

## [Why does the preprocessor do more than just compile the mod-file?](https://forum.dynare.org/t/why-does-the-preprocessor-do-more-than-just-compile-the-mod-file/27243)

<div class="topic-metadata">

**Author:** [@schoderch](https://forum.dynare.org/u/schoderch)\
**Replies:** 2\
**Last updated:** [6 March 2025 21:46 UTC](https://forum.dynare.org/t/why-does-the-preprocessor-do-more-than-just-compile-the-mod-file/27243 "2025-03-06T21:46:16Z")

</div>

This post is more of a suggestion than a specific issue. The preprocessor is a powerful tool for scaling models and embedding them within a dynamic interface. As I understand it, its primary role is to compile the mod-f…

---

## [Anticipated forward guidance shock in monetary policy](https://forum.dynare.org/t/anticipated-forward-guidance-shock-in-monetary-policy/26369)

<div class="topic-metadata">

**Author:** [@Iris777](https://forum.dynare.org/u/Iris777)\
**Replies:** 4\
**Last updated:** [6 September 2024 20:17 UTC](https://forum.dynare.org/t/anticipated-forward-guidance-shock-in-monetary-policy/26369 "2024-09-06T20:17:30Z")

</div>

Hello everyone. I am currently studying Del Negro et al. (2012): The Forward Guidance Puzzle. I want to build a similar model in Dynare, including the anticipated forward guidance shock in monetary policy, like the foll…

---

## [Dynare code errors that include two cases](https://forum.dynare.org/t/dynare-code-errors-that-include-two-cases/26096)

<div class="topic-metadata">

**Author:** [@Wendy\_J](https://forum.dynare.org/u/Wendy_J)\
**Replies:** 4\
**Last updated:** [25 July 2024 06:55 UTC](https://forum.dynare.org/t/dynare-code-errors-that-include-two-cases/26096 "2024-07-25T06:55:06Z")

</div>

Hello, dears. I am a dynare beginner, replicating the iacoviello (2005) study. I want to include both cases of non-indexed debt and indexed debt in one mod file, but I am getting an error. Let me briefly explain the app…

---

## [Problem with declaration of index](https://forum.dynare.org/t/problem-with-declaration-of-index/25618)

<div class="topic-metadata">

**Author:** [@Fra](https://forum.dynare.org/u/Fra)\
**Replies:** 8\
**Last updated:** [26 April 2024 12:39 UTC](https://forum.dynare.org/t/problem-with-declaration-of-index/25618 "2024-04-26T12:39:03Z")

</div>

Hi, I’m writing my mod.file for the master thesis and I encountered some problems. For example, now the mod doesn’t run due to an error message about wrong declaration of i (used as index in order to define the presence …

---

## [Macro-processing error 2](https://forum.dynare.org/t/macro-processing-error-2/25453)

<div class="topic-metadata">

**Author:** [@M\_P91](https://forum.dynare.org/u/M_P91)\
**Replies:** 1\
**Last updated:** [1 April 2024 12:41 UTC](https://forum.dynare.org/t/macro-processing-error-2/25453 "2024-04-01T12:41:41Z")

</div>

Hi, i am a new user of Dynare. After running my mod file(JEEM2015 file) the following error occured Unrecognized function or variable ‘policy’. Error in JEEM2015.driver (line 1366) if policy == 1 Error in dynare (lin…

---

## [Macro-processing error](https://forum.dynare.org/t/macro-processing-error/25401)

<div class="topic-metadata">

**Author:** [@M\_P91](https://forum.dynare.org/u/M_P91)\
**Replies:** 13\
**Last updated:** [1 April 2024 12:39 UTC](https://forum.dynare.org/t/macro-processing-error/25401 "2024-04-01T12:39:54Z")

</div>

Hi, i am a new user of Dynare. After running my mod file the following error occured: dynare variables.mod Starting Dynare (version 6.0). Calling Dynare with arguments: none Starting preprocessing of the model file…

---

## [Load\_params\_and\_steady\_state and macro variable](https://forum.dynare.org/t/load-params-and-steady-state-and-macro-variable/23135)

<div class="topic-metadata">

**Author:** [@dqcote](https://forum.dynare.org/u/dqcote)\
**Replies:** 3\
**Last updated:** [23 September 2023 13:10 UTC](https://forum.dynare.org/t/load-params-and-steady-state-and-macro-variable/23135 "2023-09-23T13:10:46Z")

</div>

I’m trying to use a macro variable defined when calling dynare dynare testModel Dxx=4 to load a specific stored set of parameters and steady state values using load\_params\_and\_steady\_state(strcat('testModel\_', num2str…

---

## [Loop in initval block](https://forum.dynare.org/t/loop-in-initval-block/22916)

<div class="topic-metadata">

**Author:** [@Alexhcy](https://forum.dynare.org/u/Alexhcy)\
**Replies:** 6\
**Last updated:** [18 August 2023 08:20 UTC](https://forum.dynare.org/t/loop-in-initval-block/22916 "2023-08-18T08:20:47Z")

</div>

Hello, my model is a multi-country-multi-sector model. (Origin country \* origin sector \* destination country \* destination sector). I solved for the steady state and stored inside a mat file. I load the mat file in dynar…

---

## [Loop over arguments while running dynare in matlab](https://forum.dynare.org/t/loop-over-arguments-while-running-dynare-in-matlab/22636)

<div class="topic-metadata">

**Author:** [@WALTER](https://forum.dynare.org/u/WALTER)\
**Replies:** 2\
**Last updated:** [22 June 2023 17:51 UTC](https://forum.dynare.org/t/loop-over-arguments-while-running-dynare-in-matlab/22636 "2023-06-22T17:51:05Z")

</div>

Hi community, please need helpt with this: i declare in my mod file @#if magea==0 var e\_a=1e-5; var e\_f=0; @#endif @#if magea==1 var e\_a=1e-3; var e\_f=0; @#endif @#if magea==2 var e\_a=0; var e\_f=1e-5; @#endi…

---

## [Pass a matlab string to a MACRO\_VARIABLE](https://forum.dynare.org/t/pass-a-matlab-string-to-a-macro-variable/22320)

<div class="topic-metadata">

**Author:** [@giovanma75](https://forum.dynare.org/u/giovanma75)\
**Replies:** 4\
**Last updated:** [25 April 2023 09:07 UTC](https://forum.dynare.org/t/pass-a-matlab-string-to-a-macro-variable/22320 "2023-04-25T09:07:53Z")

</div>

Dears, I would like to pass a Matlab string to a Dynare MACRO\_VARIABLE. I tried to follow verbatim this old post: https://forum.dynare.org/t/include-file-stored-as-string-variable/4502/3?u=giovanma75 with no success…

---

## [IF statements in model block](https://forum.dynare.org/t/if-statements-in-model-block/22305)

<div class="topic-metadata">

**Author:** [@silaslarsen](https://forum.dynare.org/u/silaslarsen)\
**Replies:** 1\
**Last updated:** [24 April 2023 15:09 UTC](https://forum.dynare.org/t/if-statements-in-model-block/22305 "2023-04-24T15:09:04Z")

</div>

Hi, I am very new to Dynare, and I have the following TANK model, where I have implemented a parameter “gamma” that incorporates some kind of level of adaptive expectations for one of the agents. I would like to in the 6…

---

## [Macroprocessor option, conditional directive controlled externally](https://forum.dynare.org/t/macroprocessor-option-conditional-directive-controlled-externally/20927)

<div class="topic-metadata">

**Author:** [@Clandy](https://forum.dynare.org/u/Clandy)\
**Replies:** 4\
**Last updated:** [22 August 2022 08:50 UTC](https://forum.dynare.org/t/macroprocessor-option-conditional-directive-controlled-externally/20927 "2022-08-22T08:50:22Z")

</div>

Dear professor，I wonder if there is a way to pass more than 2 value externally. Using the example in macroprocessor.pdf Example: alternative monetary policy rules @#define linear\_mon\_pol = false // or 0 … model; @#…

---

## [Running Dynare with multiple options on a script](https://forum.dynare.org/t/running-dynare-with-multiple-options-on-a-script/20704)

<div class="topic-metadata">

**Author:** [@riliatus](https://forum.dynare.org/u/riliatus)\
**Replies:** 1\
**Last updated:** [10 July 2022 11:14 UTC](https://forum.dynare.org/t/running-dynare-with-multiple-options-on-a-script/20704 "2022-07-10T11:14:59Z")

</div>

Hi everyone, I was wondering if is possible to run a Dynare model with several options since I’m running it from a script, for example, in the command window would be dynare ModelName option1 option2 option3, but into a…

---

## [If condition in model block](https://forum.dynare.org/t/if-condition-in-model-block/4918)

<div class="topic-metadata">

**Author:** [@ycycyc](https://forum.dynare.org/u/ycycyc)\
**Replies:** 4\
**Last updated:** [4 July 2022 11:51 UTC](https://forum.dynare.org/t/if-condition-in-model-block/4918 "2022-07-04T11:51:19Z")

</div>

Hello, I wonder if it is possible to define a Macro-variable to equal to a parameter. Something like parameters sig\_c; sig\_c=1; @#define sig\_c\_par=sig\_c I am trying to estimate a model using Dynare. My model has a C…

---

## [Value of local variables](https://forum.dynare.org/t/value-of-local-variables/20346)

<div class="topic-metadata">

**Author:** [@frederikgrut](https://forum.dynare.org/u/frederikgrut)\
**Replies:** 1\
**Last updated:** [13 May 2022 06:53 UTC](https://forum.dynare.org/t/value-of-local-variables/20346 "2022-05-13T06:53:12Z")

</div>

Hi all, In my mod-file i declare several local values (using #). Is the value of these variables stored anywhere or how do I acces these?

---

## [Parameter for timing](https://forum.dynare.org/t/parameter-for-timing/20042)

<div class="topic-metadata">

**Author:** [@fernando](https://forum.dynare.org/u/fernando)\
**Replies:** 2\
**Last updated:** [31 March 2022 22:43 UTC](https://forum.dynare.org/t/parameter-for-timing/20042 "2022-03-31T22:43:48Z")

</div>

Dear Dynare users. I hope you are all well. I have not found a simple solution for this, I would like to ask whether there is a way to set a parameter for the time of a variable. For instance, set L as parameter, L=2; a…

---

## [Problem with macro-loop](https://forum.dynare.org/t/problem-with-macro-loop/19252)

<div class="topic-metadata">

**Author:** [@ComeP](https://forum.dynare.org/u/ComeP)\
**Replies:** 7\
**Last updated:** [8 November 2021 18:31 UTC](https://forum.dynare.org/t/problem-with-macro-loop/19252 "2021-11-08T18:31:47Z")

</div>

Dear all, I’m using macro-loops in my .mod file to make it easier but strangely, when I want to test for one parameter to be equal to 0 or not, it’s working fine with one the loop (see line 88-90) and it’s not working w…

---

## [Using an array to assign a lot of parameters](https://forum.dynare.org/t/using-an-array-to-assign-a-lot-of-parameters/19227)

<div class="topic-metadata">

**Author:** [@ComeP](https://forum.dynare.org/u/ComeP)\
**Replies:** 4\
**Last updated:** [4 November 2021 08:55 UTC](https://forum.dynare.org/t/using-an-array-to-assign-a-lot-of-parameters/19227 "2021-11-04T08:55:47Z")

</div>

Dear all, I’ve been working with a mutli-sectoral dsge model but I want to extend the number of sectors. However, since I want to include a lot of sectors (at least 15), I find myself with a great number of parameters a…

---

## [Tex output - unwanted subscript "t"](https://forum.dynare.org/t/tex-output-unwanted-subscript-t/16072)

<div class="topic-metadata">

**Author:** [@donihue](https://forum.dynare.org/u/donihue)\
**Replies:** 28\
**Last updated:** [19 October 2021 09:35 UTC](https://forum.dynare.org/t/tex-output-unwanted-subscript-t/16072 "2021-10-19T09:35:01Z")

</div>

Hello, The Tex output option is extremely useful, made better recently with the addition of the model\_local\_variable command. Unfortunately, when local parameter definitions thus created are subsequently transferred by…

---

## [Loop over variables instead of parameters in one model](https://forum.dynare.org/t/loop-over-variables-instead-of-parameters-in-one-model/18973)

<div class="topic-metadata">

**Author:** [@freefish](https://forum.dynare.org/u/freefish)\
**Replies:** 6\
**Last updated:** [29 September 2021 15:39 UTC](https://forum.dynare.org/t/loop-over-variables-instead-of-parameters-in-one-model/18973 "2021-09-29T15:39:04Z")

</div>

Hi all, I want to loop over several variables in one model, but didn’t find any similar examples in the forum.What I see are mostly about looping over parameters or values of variables, in these cases the matlab command…

---

## [Parameters dependent Macro expressions problem](https://forum.dynare.org/t/parameters-dependent-macro-expressions-problem/18734)

<div class="topic-metadata">

**Author:** [@ahnulxy](https://forum.dynare.org/u/ahnulxy)\
**Replies:** 4\
**Last updated:** [21 August 2021 01:52 UTC](https://forum.dynare.org/t/parameters-dependent-macro-expressions-problem/18734 "2021-08-21T01:52:21Z")

</div>

Dynare always complains unknown variables when I put parameters (like parameter lam in the following code) in macro-expressions. I have to do some algebra for lam within the mod file. So it is not convinenent to use -D o…

---

## [Country-specific definitions in multi-country model](https://forum.dynare.org/t/country-specific-definitions-in-multi-country-model/18384)

<div class="topic-metadata">

**Author:** [@tintin\_milou](https://forum.dynare.org/u/tintin_milou)\
**Replies:** 3\
**Last updated:** [28 June 2021 09:28 UTC](https://forum.dynare.org/t/country-specific-definitions-in-multi-country-model/18384 "2021-06-28T09:28:03Z")

</div>

Hi, In a multi-country model, I’ve got some countries with a fixed exchange rate and others with a floating exchange rate. Suppose I store this information in the numerical vector fixed = \[0 0 1 1 1\] in matlab, where co…

---

## [Using external mod file](https://forum.dynare.org/t/using-external-mod-file/18366)

<div class="topic-metadata">

**Author:** [@nithinmkp](https://forum.dynare.org/u/nithinmkp)\
**Replies:** 8\
**Last updated:** [25 June 2021 19:22 UTC](https://forum.dynare.org/t/using-external-mod-file/18366 "2021-06-25T19:22:10Z")

</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…

---

## [Changing macro\_expression outside of the .mod file](https://forum.dynare.org/t/changing-macro-expression-outside-of-the-mod-file/18374)

<div class="topic-metadata">

**Author:** [@mat1339](https://forum.dynare.org/u/mat1339)\
**Replies:** 2\
**Last updated:** [22 June 2021 10:19 UTC](https://forum.dynare.org/t/changing-macro-expression-outside-of-the-mod-file/18374 "2021-06-22T10:19:00Z")

</div>

Dear all, is it possible to change the expression of a MACRO\_VARIABLE outside of the .mod file? For example, I would like to be able to specify whether “deterministic\_simul” is true or false in another Matlab file. Is …

---

## [Refer to specific element of macro vector](https://forum.dynare.org/t/refer-to-specific-element-of-macro-vector/18230)

<div class="topic-metadata">

**Author:** [@tintin\_milou](https://forum.dynare.org/u/tintin_milou)\
**Replies:** 2\
**Last updated:** [4 June 2021 16:07 UTC](https://forum.dynare.org/t/refer-to-specific-element-of-macro-vector/18230 "2021-06-04T16:07:42Z")

</div>

Hi, I saw the following example on the slides for the dynare summer school 2019 on the macro-processing language. I wonder if it is possible to adapt this example such that the nth\_co is not the US, but simply the first…

---

## [Output post macro-processed mod file](https://forum.dynare.org/t/output-post-macro-processed-mod-file/18002)

<div class="topic-metadata">

**Author:** [@Yaakov](https://forum.dynare.org/u/Yaakov)\
**Replies:** 2\
**Last updated:** [28 April 2021 09:17 UTC](https://forum.dynare.org/t/output-post-macro-processed-mod-file/18002 "2021-04-28T09:17:47Z")

</div>

Hi everyone, Is there any way to save the post macro-processed mod file? I have a model with macro commands, and I would like to use the macro processor to get the full file that dynare compiled. Many thanks.

[Next page](https://forum.dynare.org/c/macrolanguage/23.md?page=1)
