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
Graph line with values for only a few groups over timeHi, I want to graph the development of the number of houses of the type "allmännyttan" (publicly ow…
Combining Monthly and Yearly DataI am working on inflation time series data. I have Yearly and Monthly data but cannot do tset becaus…
Pearson's Chi Square - interested in the significance of one rowHi please see my output: Code: . tabulate tv3 group , chi2 cchi2 +-------------------+ | Key …
heteroskedastic ordered probit with survey dataI am running an ordered probit model using survey data (svy) and trying to test for heteroskedastict…
Set Dummy Variable = 1 if the Dummy Variable left to it == 1Hello everybody, I'm stuck on a very basic problem, I think. I need to set a dummy variable (year) …
Subscribe to:
Post Comments (Atom)
0 Response to Re: Converting a string variable to a date variable
Post a Comment