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
creating new variable matching a definitionHello, I am reposting this, as the previous one had some typos. I need to count the diffuse nodule…
oaxaca, relax and interpretationDear all, I am using oaxaca to compare two groups in survey data. I include industrie dummies. Beca…
create dummy variables for children educationHi I want to create four separate dummy variables at household level: 1. No children between 5 and …
How to cluster the standard error?Hi, I am new to Statalist forum. Hope someone can explain to me the issue that I am going through. …
foreach copula command* - Syntax errorDear Stata members i have been trying to make a foreach command to estimate all 6 types of copula m…
Subscribe to:
Post Comments (Atom)
0 Response to using local as range in for values
Post a Comment