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
Fixed Effects Pooled OLS Panel Data RegressionDear all, Thanks for your time reading this. My data has small T and large N. When I use Hausman t…
Help on Writing out Regression Equation for Panel Data inc. Industry and Time DummiesHello, I'm trying to write out my regression equation inc. industry and time dummies, but I'm not s…
generating dummy variablesDear all, I have the following data coming from a lab experiment from multiple sessions. Under each…
Splitting one variable containing two variable dataHello I have a variable 'implementscheme' which contains the names of various agriculture implements…
Help with regression, binary independent variable with moderatorsDear all I'm fairly new with Stata and I have done my best to search for previous questions which a…
Subscribe to:
Post Comments (Atom)
0 Response to Two linked variable loops
Post a Comment