I have some code that cycles through values in some nested `foreach` loops to simulate a conditional summation. Unfortunately, this seems to be creating a missing value which I can confirm by using

```
display `var'

```

I have tried searching for `+=` operator in Stata but I do not find one.
I am also confused by this behavior.
I tried assigning 10 to `topTerm` instead of 0 to see if the variable was floored but that was not the case.

```
tempname topTerm bottomTerm controlledContrast
scalar `topTerm' = 0

foreach … numlist {
  foreach … numlist {
    foreach … numlist {
              display `delta', `topTerm'
              scalar `topTerm'= `topTerm' + `delta'*`cc_difference_in_means'*`cc_vet_n'
              display `topTerm'
}}}

```

EDIT: Tried using local/global and still getting missing values. Seems to be a problem of scope, though I figured local would fix that so I'm really confused…

Note that this works from command line:

```
local x = 10
local x = `x' + 10
display `x'
>> 20

```