Hello everyone!
I have a dataset with monthly data. My date variable is in the format of "YM", so, e.g. "1983m1" (type = float, format =%tm)
Now, for each monthly observation, I want to create a month-of-the-year dummy for my regression.
I already tried the following code from another fellow member of the forum:
egen month =seq(), to (12)
tab month, gen(m)
Technically, this works perfectly fine. However, the problem is that sometimes, I have a month missing in my observation so that at one point, the month-of-the year dummies and my date variable are not running in sync anymore.
Is there a way that I can create my dummies directly based on my date variable? So that e.g. if my date variable jumps from "1983m1" directly to "1983m3", my month-of-the year dummy would also jump from "1" to "3" ?
Already thanks a lot for your time and support!
Related Posts with Creating month-of-the-year dummies
Help: Interpreting ordinal logistic outputI'm trying to interpret a simple stata output for ologit and somehow keep getting confused: A little…
In Stata, how to transfer matrix to LaTeX table?I have a matrix, which contains all the numbers I want. Now I need to design a table in LaTeX and us…
Can anyone help me loop these lengthy codes? Code: matrix table1=J(6,6,.) ttest preaddition == postaddition matrix table1[1,1] = r(mu_1) matrix…
when should I use program?I start to read program tutorial in Stata. But I'm still confused when I should use program. …
can anyone share a template of beginning of do file?Currently, I just have three lines at the beginning of my do file. What do you think? Code: clear …
Subscribe to:
Post Comments (Atom)
0 Response to Creating month-of-the-year dummies
Post a Comment