# Dseries "insert" doesn't carry the new index

**URL:** https://forum.dynare.org/t/dseries-insert-doesnt-carry-the-new-index/22386
**Category:** dseries/data/reporting
**Created:** [3 May 2023 07:51 UTC](https://forum.dynare.org/t/dseries-insert-doesnt-carry-the-new-index/22386 "2023-05-03T07:51:13Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![sik](https://forum.dynare.org/letter_avatar_proxy/v4/letter/s/958977/32.png) [@sik](https://forum.dynare.org/u/sik)
#### Post date: [3 May 2023 07:51 UTC](https://forum.dynare.org/t/dseries-insert-doesnt-carry-the-new-index/22386/1 "2023-05-03T07:51:13Z")

</div>

Hello all,

As per title. I have tried this with Dynare 5.3. Could you confirm if you’re having a similar issue?

Replication:

> load acetylene.mat  
> ds\_example = dseries(y)  
> size(ds\_example)  
> ds\_nan = dseries(NaN, ds\_example.dates, “inserted\_Variable”)  
> ds\_example1 = insert(ds\_example, ds\_nan{1}, 1) % we succesfully insert a variable  
> size(ds\_example1) % check what we’ve done  
> ds\_example1{1} % works  
> ds\_example1{end} % doesn’t work (ds\_example1{2} and ds\_example1{‘Variable\_1’} don’t work either)

---

<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: [3 May 2023 12:07 UTC](https://forum.dynare.org/t/dseries-insert-doesnt-carry-the-new-index/22386/2 "2023-05-03T12:07:41Z")

</div>

Can you please provide the files to replicate the issue?

---

<div class="post-metadata">

### Author: ![sik](https://forum.dynare.org/letter_avatar_proxy/v4/letter/s/958977/32.png) [@sik](https://forum.dynare.org/u/sik)
#### Post date: [3 May 2023 12:20 UTC](https://forum.dynare.org/t/dseries-insert-doesnt-carry-the-new-index/22386/3 "2023-05-03T12:20:59Z")

</div>

Hello and thanks for the prompt response.

I have provided a replicable block of code with the sample dataset acetylene.mat. I think one should pretty much be able to run the code exactly as I have it.

---

<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: [3 May 2023 12:34 UTC](https://forum.dynare.org/t/dseries-insert-doesnt-carry-the-new-index/22386/4 "2023-05-03T12:34:54Z")

</div>

No, you did not provide the dataset.

---

<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: [3 May 2023 12:42 UTC](https://forum.dynare.org/t/dseries-insert-doesnt-carry-the-new-index/22386/5 "2023-05-03T12:42:32Z")

</div>

My mistake, I did not know it’s a Matlab example data set. I can confirm that the code

```auto
clear all
load acetylene.mat
ds_example = dseries(y)
size(ds_example)
ds_nan = dseries(NaN, ds_example.dates, "inserted_Variable")
ds_example1 = insert(ds_example, ds_nan{1}, 1) % we succesfully insert a variable
size(ds_example1) % check what we’ve done
ds_example1{1} % works
ds_example1{end} % doesn’t work (ds_example1{2} and ds_example1{‘Variable_1’} don’t work either)

```

does not run, presumably due to a problem with the command history. You can keep track of the bug at [Fix crash after using insert (#53) · Issues · Dynare / dseries · GitLab](https://git.dynare.org/Dynare/dseries/-/issues/53)

---

<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: [12 May 2023 20:01 UTC](https://forum.dynare.org/t/dseries-insert-doesnt-carry-the-new-index/22386/6 "2023-05-12T20:01:01Z")

</div>

The bug should be fixed in the current unstable version.

---

<div class="post-metadata">

### Author: ![sik](https://forum.dynare.org/letter_avatar_proxy/v4/letter/s/958977/32.png) [@sik](https://forum.dynare.org/u/sik)
#### Post date: [13 May 2023 20:08 UTC](https://forum.dynare.org/t/dseries-insert-doesnt-carry-the-new-index/22386/7 "2023-05-13T20:08:47Z")

</div>

Thank you very much, I’ll give it a go!
