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
IntegrationHello everyone, Does anyone know how to do a granger test with a variable I(0) and a variable I(1)?…
How to calculate the cumulative mean with different weights by groups?How to calculate the cumulative mean with different weights by groups? The weight is variable: order…
Absence of difference in Hansen test in xtabond2 and difference between suboptions equation(level) and equation(diff) in ivstyleDear statalists, I'm learning how to use the command xtabond2, but I'm not sure about a few things …
Multiple rows in x-axis (months and years in t-axis)I'm currently working with some data that I need visualized over time since March 2020. I'm using la…
First order factor analysisHi everyone! I am estimating a first order confirmatory factor analysis . When I get teh results I d…
Subscribe to:
Post Comments (Atom)
0 Response to Check if variable at datetime equal variable at datetime + 24 hours
Post a Comment