Hello,
My date variable (moyr) could not be used when I declared my dataset to be monthly panel data. As seen below, moyr is a string variable that is composed of YYYY-MM.
. list moyr in 1/5
+---------+
| moyr |
|---------|
1. | 2017-01 |
2. | 2017-02 |
3. | 2017-03 |
4. | 2017-04 |
5. | 2017-05 |
+---------+
Thus, I generate a new date variable by using the code: generate date = date(moyr,"YM"). However, values for the date variable are not readable.
. list moyr date in 1/5
+-----------------+
| moyr date |
|-----------------|
1. | 2017-01 20820 |
2. | 2017-02 20851 |
3. | 2017-03 20879 |
4. | 2017-04 20910 |
5. | 2017-05 20940 |
+-----------------+
Thus, I reformatted the date variable to be YYYY-MM using the code: format %tmCCYY-NN date.
. list moyr date in 1/5
+-------------------+
| moyr date |
|-------------------|
1. | 2017-01 3695-01 |
2. | 2017-02 3697-08 |
3. | 2017-03 3699-12 |
4. | 2017-04 3702-07 |
5. | 2017-05 3705-01 |
+-------------------+
However, values in the date variable are still not readable. Any advice would be greatly appreciated. Thank you.
Related Posts with Re: Converting a string variable to a date variable
two way scatterI have a problem with two way scatter. I am using the following command to plot as in the followin…
rologit predict stdpHello, I am performing an rank-ordered logit analysis using the rologit Stata command. In post-esti…
Convergence not achieved (error 430) Dear STATALIST, I am estimating an endogenous switching regression model using the 'movestay' com…
Generate X(t) = 0.7X(t-1) + epHow to generate a series X(t) = 0.7*X(t-1) + ep where X(0) = 10 , ep is normal(0,1) and t = 1, 2, ..…
Reshape wide -- categories as variables Code: +---------------------------------------------------------------------------------------…
Subscribe to:
Post Comments (Atom)
0 Response to Re: Converting a string variable to a date variable
Post a Comment