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
Date format issueHi Is there a way to convert dates that have a format such as September 13 2005 to a date variable …
xtline graphical questionDear All, I have the following code Code: use "dta\cf_index.dta", clear keep if year > 1965 en…
How to place coefficient at a certain value in “coefplot”Dear All, I come across an error when using the 'coefplot' command. I want to plot the coefficient o…
Levelsof questionHi, I am trying to understand how levelsof works. - is it possible to use local labels as labels fo…
low Cronbach's alphaHi, I am currently in the initial stage of my research and don't have much experience in statistica…
Subscribe to:
Post Comments (Atom)
0 Response to Two linked variable loops
Post a Comment