Hi there,
I’m fairly new to Stata and would really appreciate some advice with coding.
I’m looking at time survey data, with 144 variables, each for ten minute slots of an individual’s day (running from “act1_1” to “act1_144”) and am trying to create a new variable counting every individual who went to sleep (activities defined by “110” and “111”) within an hour of using electronics (group of activities defined with codes between “7220” and “7259”).
I’ve been trying the below code to create a “sleephygiene” variable to count instances of an individual using tech within 6 time slots of going to sleep, but I keep getting a syntax error message.
forvalues i = 1/138 {
forvalues j = `= `i' + 6' {
replace sleephygiene = sleephygiene+1 if (act1_`i’ > 7219 & act1_`i’ < 7260 & act1_`j’ > 109 & act1_`j’ < 112)
}
}
Could anyone please point out where I might be going wrong?
Thanks,
Luke
Related Posts with Two linked variable loops
Metanalysis without controll group I am conducting a meta-analysis study for the first time. There is no comparison group. As a measur…
quantile for dynamic panelHi Do anyone read the paper of Galvao (2011) about quantile regression for dynamic panel data with f…
xtvireg excel outputHi, I am working on a model with instrumental variables, I would like the output to be exported to e…
How to store each estimate of multiple regressions in a loop commandHi, I am running regression commands similar to the followings: logit y cov1 cov2 cov3 cov4 cov…
Convergence not achieved in technical efficiency modelHi All, When I am running my frontier model (panel data) I got the message called "convergence not …
Subscribe to:
Post Comments (Atom)
0 Response to Two linked variable loops
Post a Comment