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
plotting interaction for xtpoissonHi Statalist fellow, I have run an analysis but I don't trust my result. I would be extremely apprec…
Manipulating panel data based on previous time valuesHi, I am working with a district-year panel data set in which there are 10 years. I am interested i…
synthetic control errorHello, I am new at the synth command. I am using Stata 15. I want to estimate a treatment effect us…
Differences in margins postestimation command for tpoisson relative to poissonI'm currently using a truncated poisson model with command tpoisson and ll(0) and ul(6) for a depend…
Extract Std.Err. and 95% Conf. Interval after regressionHi Statalist After running a regression, I understand we can extract the estimated coefficients in …
Subscribe to:
Post Comments (Atom)
0 Response to Check if variable at datetime equal variable at datetime + 24 hours
Post a Comment