
*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ò
0 Response to Converting globals in to scalars
Post a Comment