Hi, I have 12 observations per year, each for each month, but with the same date. I would want to create a new variable called month where it just assigns the number of the month to each observation. This is what my dataset looks like:
And I would want something like this:
What is an easy way to do this?
Thanks
Code:
* Example generated by -dataex-. For more info, type help dataex clear input long gvkey int year str10 datadate float lvratio 246759 1999 "31/12/1999" .5424352 246759 1999 "31/12/1999" .5424352 246759 1999 "31/12/1999" .5424352 246759 1999 "31/12/1999" .5424352 246759 1999 "31/12/1999" .5424352 246759 1999 "31/12/1999" .5424352 246759 1999 "31/12/1999" .5424352 246759 1999 "31/12/1999" .5424352 246759 1999 "31/12/1999" .5424352 246759 1999 "31/12/1999" .5424352 246759 1999 "31/12/1999" .5424352 246759 1999 "31/12/1999" .5424352 246759 2000 "31/12/2000" .7837051 246759 2000 "31/12/2000" .7837051 246759 2000 "31/12/2000" .7837051 246759 2000 "31/12/2000" .7837051 246759 2000 "31/12/2000" .7837051 246759 2000 "31/12/2000" .7837051 246759 2000 "31/12/2000" .7837051 246759 2000 "31/12/2000" .7837051 end
Code:
* Example generated by -dataex-. For more info, type help dataex clear input long gvkey int year str10 datadate float lvratio month 246759 1999 "31/12/1999" .5424352 1 246759 1999 "31/12/1999" .5424352 2 246759 1999 "31/12/1999" .5424352 3 246759 1999 "31/12/1999" .5424352 4 246759 1999 "31/12/1999" .5424352 5 246759 1999 "31/12/1999" .5424352 6 246759 1999 "31/12/1999" .5424352 7 246759 1999 "31/12/1999" .5424352 8 246759 1999 "31/12/1999" .5424352 9 246759 1999 "31/12/1999" .5424352 10 246759 1999 "31/12/1999" .5424352 11 246759 1999 "31/12/1999" .5424352 12 246759 2000 "31/12/2000" .7837051 1 246759 2000 "31/12/2000" .7837051 2 246759 2000 "31/12/2000" .7837051 3 246759 2000 "31/12/2000" .7837051 4 246759 2000 "31/12/2000" .7837051 5 246759 2000 "31/12/2000" .7837051 6 246759 2000 "31/12/2000" .7837051 7 246759 2000 "31/12/2000" .7837051 8 end
Thanks

Comment