Hi all I have a question. During my .do file I created some globals in which I stored the value of some previously defined scalars. I need to reconvert these globals into scalars in order to do some aritmetical operations. This is how the code looks like:


*generate the globals

global country = "IT UK FR"
global year = "2018 2019"
global vars = "x y z"

foreach ctr of global country {
foreach yrs of global years {
foreach var of global vars {
scalar `ctr'_`yrs'_name = 0
...
scalar `ctr'_`yrs'_x = scalar(`ctr'_`yrs'_name) + x
global `ctr'_`yrs'_x = `ctr'_`yrs'_x
...
scalar `ctr'_`yrs'_y = scalar(`ctr'_`yrs'_name) + y
global `ctr'_`yrs'_y = `ctr'_`yrs'_y
...
clear
}

*display the content of the globals

dis `ctr'_`yrs'_x
dis `ctr'_`yrs'_y

-> here I'd like to sum the two and divide all by "z"
(`ctr'_`yrs'_x + `ctr'_`yrs'_y) / z

}
}

I converted scalars in globals becuase I gave the command clear at the end of the third loop (I used clear since actually this third loop loops different datasets) and, if I'm right, clear delets scalars but not globals. Now, at the end of the third loop, in running the second loop, I need to do the mathematical operations with my globals.
How can I do?

Thank you in advance
Nicolò