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
Dropping Variables with Multiple Conditions.Hi, Statalist. I'm trying to clean a dataset. This is a small snippet below...I deleted some variabl…
problem plotting latitude and longitude using grmapDear Statalists, I am having some problem in plotting latitude and longitude on a map I have perform…
New version of kmest for SSCThanks yet again to Kit Baum, a new version of the kmest package (superseding last week's versions) …
Relabeling ValuesThis is my first time using Stata without help from a professor, and I am struggling to relabel my v…
Replicate TableHello, I am trying to replicate the below table, but I'm not sure which command to use. The "final …
Subscribe to:
Post Comments (Atom)
0 Response to using local as range in for values
Post a Comment