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
margianl effect of tobit model after GSEMHello all, I have a structure model as below Code: gsem ($x <- shock $xfirm_control i.year) //…
Generating a var based on a factor in entire datasetHello, My dataset contains minute by minute stock market data for 200 companies AND if there was an…
How to create a table of means and differences of variablesHello everyone I am new to Stata and statistics in general. I am looking to replicate the following…
totals in tabout don't matchHi! I'm following the beneficial and good guide "Publication quality tables in Stata: a tutorial fo…
Find and Replace in Selection Stata (17) for MacIs the find and replace *in selected text* function available for State 17 in Mac? This post implies…
Subscribe to:
Post Comments (Atom)
0 Response to using local as range in for values
Post a Comment