I have example data as follows:

```
library(data.table)
datA <- fread("ID somevar
               NA 4
               NA  3
               2  5")
datB <- fread("ID somevar
               7   4
               NA  3
               NA  5")
dat_list <- list(datA, datB)

```

In dat\_list I would like to replace all `NA`'s in the `ID` column with a new `ID`-number.

I would like this number to be unique and start at `100`. I thought of something like this:

```
for (i in seq_along(dat_list)){
  temp <- dat_list[[i]]
  count_of_seq <- sum(is.na(temp$ID))
  sequence_dat <- seq(100, 100+count_of_seq)
  temp <- setDT(temp)[is.na(ID), ID:=sequence_dat[i]]
}

```

But this does not work because, it uses only one number of the sequence for each list:

[![enter image description here](https://i.stack.imgur.com/bB5M1.png)](https://i.stack.imgur.com/bB5M1.png)

How should I do this properly?

Desired output:

```
library(data.table)
datA <- fread("ID somevar
               100 4
               101  3
               2  5")
datB <- fread("ID somevar
               7   4
               102  3
               103  5")
dat_list <- list(datA, datB)

```