Hi Statalist
I would like to run a loop for every value within a variable called "spell_count", and then run the whole do.file as a loop for different datasets, where the range for "spell_count" changes.
In file one the range is 1 - 82. So I can run
forvalues n = 1(1)82 {
if spell_count == `n' (etc etc)
}
but as the range in spell count changes across datasets, I would like to specify the range as a local, and then use this within the for values command.
I can define the range using a local, but then get an error when I put this in to forvalues:
quitetly sum spell_count
local max = `r(max)'
local min = `r(min)'
forvalues n = `min'(1)`max' {
if spell_count == `n' (etc etc)
}
Does anyone know what I am doing wrong?
Best Wishes
Joe
Related Posts with using local as range in for values
Combining two discrete variables into one percentageI'm trying to combine two discrete variables, in this case, cmarried - number of children from marri…
Hadri LM unit root testHi all, I use balanced panel data N=43, T=24 and I want to use Hadri LM unit root test for initial …
Changing reference category in categorical variable gives more significant resultsHi everyone! I am new to statistics so I guess there is an obvious answer to this question, but I f…
Why does country effects in fixed effects model are omitted?Hi everyone, I am running a fixed effects regression. Upon choosing "i.country" for country fixed ef…
Probit lagged variables- panel dataDear Statalist members, I'm trying to write my dissertation and need your help -I am new to Stata. …
Subscribe to:
Post Comments (Atom)
0 Response to using local as range in for values
Post a Comment