# Error code:Error: unexpected '{' in "data {"

**URL:** <https://discourse.mc-stan.org/t/error-code-unexpected-in-data/33025>\
**Category:** Modeling\
**Tags:** rstan, techniques\
**Created:** [October 9, 2023, 2:06pm UTC](https://discourse.mc-stan.org/t/error-code-unexpected-in-data/33025 "2023-10-09T14:06:08Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![jia](https://avatars.discourse-cdn.com/v4/letter/j/bbce88/32.png) [@jia](https://discourse.mc-stan.org/u/jia)\
**Post date:** [October 9, 2023, 2:06pm UTC](https://discourse.mc-stan.org/t/error-code-unexpected-in-data/33025/1 "2023-10-09T14:06:08Z")

</div>

Hi guys, I’m running into an issue when trying Stan,  
When trying to set the model, the Rstudio failed to run the following codes.

## data { int\<lower=0\> J; array[J] real y; array[J] real\<lower=0\> sigma; } parameters { real mu; // population treatment effect real\<lower=0\> tau; // standard deviation in treatment effects vector[J] eta; // unscaled deviation from mu by school } transformed parameters { vector[J] theta = mu + tau \* eta; // school treatment effects } model { target += normal\_lpdf(eta | 0, 1); // prior log-density target += normal\_lpdf(y | theta, sigma); // log-likelihood }

## Error: unexpected ‘{’ in “data {”

it seems to be a unicode character issues, however, I could not find any way to solve this.

thank you for helping.

---

<div class="post-metadata">

**Author:** ![kholsinger](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/kholsinger/32/4498_2.png) [@kholsinger](https://discourse.mc-stan.org/u/kholsinger)\
**Post date:** [October 9, 2023, 6:48pm UTC](https://discourse.mc-stan.org/t/error-code-unexpected-in-data/33025/2 "2023-10-09T18:48:06Z")

</div>

How are you trying to run the code? Are you using `rstan` or `cmdstanr`? With `rstan` you’ll need to store that code in a variable and use the `model_code` argument or store it in an external file and use the `file` argument. With `cmdstanr` you’ll need to store it in an external file and use the `stan_file` argument to `cmdstan_model`.

---

<div class="post-metadata">

**Author:** ![Corey.Plate](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/corey.plate/32/20600_2.png) [@Corey.Plate](https://discourse.mc-stan.org/u/Corey.Plate)\
**Post date:** [October 9, 2023, 9:24pm UTC](https://discourse.mc-stan.org/t/error-code-unexpected-in-data/33025/3 "2023-10-09T21:24:19Z")

</div>

I combed through the code carefully and didn’t see any issues that were obvious to me, so I saved this into a plain text document (.txt), changed the extension to .stan, and attempted to compile it with `MatlabStan`. It went through to completion without any issues. This may be a file type/extension issue or `rstan` itself may not like something, because the code itself seems fine.

---

<div class="post-metadata">

**Author:** ![jia](https://avatars.discourse-cdn.com/v4/letter/j/bbce88/32.png) [@jia](https://discourse.mc-stan.org/u/jia)\
**Post date:** [October 10, 2023, 12:41pm UTC](https://discourse.mc-stan.org/t/error-code-unexpected-in-data/33025/4 "2023-10-10T12:41:40Z")

</div>

I was been dumb, was ran into problem when save a stan file, and then tried to run it directly through R which gets this Error, because I have not able to actually change the text file extension to stan… But thanks, I have sorted out !
