# IF statements in model block

**URL:** <https://forum.dynare.org/t/if-statements-in-model-block/22305>\
**Category:** Macro-language\
**Created:** [19 April 2023 14:44 UTC](https://forum.dynare.org/t/if-statements-in-model-block/22305 "2023-04-19T14:44:19Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![silaslarsen](https://forum.dynare.org/letter_avatar_proxy/v4/letter/s/919ad9/32.png) [@silaslarsen](https://forum.dynare.org/u/silaslarsen)\
**Post date:** [19 April 2023 14:44 UTC](https://forum.dynare.org/t/if-statements-in-model-block/22305/1 "2023-04-19T14:44:19Z")

</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 6th equation in the model block to add an if statement that makes it the following:

```auto
If gamma = 0
q-sigma_H*c_H = -(1-beta*(1-delta))*chi_H*x_H+beta*(1-delta)*(q(+1)-sigma_H*c_H(+1))
else
q-sigma_H*c_H = -(1-beta*(1-delta))*chi_H*x_H+beta*(1-delta)*(gamma^2*q(-1)-sigma_H*c_H(+1))
endif

```

I tried using @#if directly in the model block, although this did not work.

Could anybody advise?  
[kladde5.mod](https://forum.dynare.org/uploads/short-url/42GnLDgApWSGCW5l7LKgnE4LBix.mod) (5.3 KB)

Thanks!

---

<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 April 2023 15:09 UTC](https://forum.dynare.org/t/if-statements-in-model-block/22305/2 "2023-04-24T15:09:04Z")

</div>

You cannot condition on the value of a parameter using the macro processor. But you can define a macro-switch to set `gamma` and then condition on that macro-switch. See e.g. the `sticky_prices`-switch:

> <https://github.com/JohannesPfeifer/DSGE_mod/blob/master/Basu_Bundick_2017/Basu_Bundick_2017.mod>
