I have a dataset akin to this
User Date Value
A 2012-01-01 4
A 2012-01-02 5
A 2012-01-03 6
A 2012-01-04 7
B 2012-01-01 2
B 2012-01-02 3
B 2012-01-03 4
B 2012-01-04 5
I want to create a lag of Value, respecting User.
User Date Value Value.lag
A 2012-01-01 4 NA
A 2012-01-02 5 4
A 2012-01-03 6 5
A 2012-01-04 7 6
B 2012-01-01 2 NA
B 2012-01-02 3 2
B 2012-01-03 4 3
B 2012-01-04 5 4
how can i do this in stata??
Related Posts with How to find lag of a variable in long format panel dataset?
how to write the loop statement?I want to write a loop statement to generate a lot of rowmean? How to write such loop statement? Her…
eclass store resultsDear stata users, I would like to store a matrix and the number of observations after my eclass pro…
Help with boostrap code for indirect effects using gsemHello, I am trying to obtain coefficients, bootstrap standard errors and percentile CI for an indire…
unknown function () in a simple generate commandHi, I am trying to generate a new variable b with the following formula using all existing variable…
Reverse the color of spmapHello Stata-Experts, I generated a wonderful heat map with the spmap package. Now I am wondering if…
Subscribe to:
Post Comments (Atom)
0 Response to How to find lag of a variable in long format panel dataset?
Post a Comment