Good day,
I have two variables (among others): One variable is a binary variable 0 or 1 (sleepwake). The other variable (datetime) is date followed by time (in %tc format). There are 7 days worth of rows, at 15-sec intervals. I want to create a new variable, called "sri", and I want to replace sri for datetime with 0 if sleepwake at datetime != sleepwake at datetime + 24 hours, and I want to replace sri for datetime with 1 if sleepwake at datetime == sleepwake at datetime + 24h. sri for the last day must be "." since there is no sleepwake for datetime + 24 hours to compare with.
datetime sleepwake sri
24feb2017 18:01:30 0 0
24feb2017 18:01:45 0 1
24feb2017 18:02:00 0 1
24feb2017 18:02:15 1 1
24feb2017 18:02:30 1 1
...
25feb2017 18:01:30 1 .
25feb2017 18:01:45 0 .
25feb2017 18:02:00 0 .
25feb2017 18:02:15 1 .
25feb2017 18:02:30 1 .
Please help me find a solution.
Thanks so much.
Related Posts with Check if variable at datetime equal variable at datetime + 24 hours
Panel data estimatioinHello. Need help with panel data estimation. I am working on panel data with T=96 and N=260. I used …
Number of splitvoters from two variablesI need to know the number of split voters in Denmark - those who did not vote for the same party at …
Cmxtmixlogit discrete choice experiment with choice card blocksDear all, I am encountering a convergence problem with the 'cmxtmixlogit' command, using STATA 16.1…
zero-inflated and right-censored count dataDear all statalists, Thank you for clicking on my post. What is the proper way to deal with zero-in…
converting dates (year and month)Dear All, Is there a more concise way to go from date to newdate below? Thanks. Code: * Example gen…
Subscribe to:
Post Comments (Atom)
0 Response to Check if variable at datetime equal variable at datetime + 24 hours
Post a Comment