Dear Experts,
I have a piece of code , where a local multiplier is generated in a loop and is suppoesed to be dropped at the end of each cycle of local Seq.
A new local multiplier should be defined for each n of local Seq.
This code works, but local multiplier seems not to be dropped at the end. It runs correctly for the first n of local Seq, but for the next n it adds to the local multiplier from the previous n.
Any advice is very much appreciated.
Sincerely,
Pavlo
I have a piece of code , where a local multiplier is generated in a loop and is suppoesed to be dropped at the end of each cycle of local Seq.
A new local multiplier should be defined for each n of local Seq.
Code:
su groups_`i', meanonly
forvalues k = 1/`r(max)' {
levelsof min_Sequence_num if groups_`i' == `k', local(Seq)
foreach n of local Seq {
local t : label min_Sequence `n'
display "`t'"
foreach var of global var_of_interest {
quietly: summarize `var'_sub_var if groups_`i' == `k' & min_Sequence_num == `n'
local `var'_gr = r(mean) + 1
if (``var'_gr' == .) local `var'_gr = 1
if (``var'_gr' == 0) local `var'_gr = 1
local multiplier = "`multiplier'" + "*" + "``var'_gr'"
di "`multiplier'"
}
local multiplier = substr("`multiplier'", 2, .)
local b1_x1 = `b_x1' * `multiplier'
local b1_x2 = `b_x2' * `multiplier'
macro drop multiplier
}
}
Any advice is very much appreciated.
Sincerely,
Pavlo

Comment