Hi guys,
I have a feeling I'm not the first with this problem, but I just can not find anywhere on the internet the solution to my extremely time-consuming problem.
So, I'm trying to analyze a dataset from 1962 until 2008 with monthly data. It is a string variable when I paste it into the data editor and it is a YMD format, which means day is 01 everytime.
I've seen a youtube video from Stata how to convert a string variable in a floating variable and that works for me, but my problem is as follows:
String variable starts January 1962 and goes on like that. Converting it to a floating variable 'gen t1 = date(t0, "YMD") results in stata listing the variable in days starting from 1960.
(731 for Jan-1962, 762 for Feb-1962 etc). Now, that is not how I want my variable to look, so I try to convert that back to months. Instead of correctly converting it back to Jan/Feb/Mar 1962, it pretens like days are months. So Jan-1962 is 731, Feb-1962 is 762 in days, but it converts these days like they are months. In other words, suddenly my first time variable datapoint starts in december 2020, the second is july 2023 and so on and so on.
I get it that stata has a system that counts days from 1960 onwards, but what I don't get is that it suddenly interprets these days as months when I want to convert the variable......
Help me out please...
(I need the data to be a suitable monthly time-series so that I can perform dfuller test. It won't do that at the moment because I've got a 'daily time series with gaps')
Thanks in advance
I have a feeling I'm not the first with this problem, but I just can not find anywhere on the internet the solution to my extremely time-consuming problem.
So, I'm trying to analyze a dataset from 1962 until 2008 with monthly data. It is a string variable when I paste it into the data editor and it is a YMD format, which means day is 01 everytime.
I've seen a youtube video from Stata how to convert a string variable in a floating variable and that works for me, but my problem is as follows:
String variable starts January 1962 and goes on like that. Converting it to a floating variable 'gen t1 = date(t0, "YMD") results in stata listing the variable in days starting from 1960.
(731 for Jan-1962, 762 for Feb-1962 etc). Now, that is not how I want my variable to look, so I try to convert that back to months. Instead of correctly converting it back to Jan/Feb/Mar 1962, it pretens like days are months. So Jan-1962 is 731, Feb-1962 is 762 in days, but it converts these days like they are months. In other words, suddenly my first time variable datapoint starts in december 2020, the second is july 2023 and so on and so on.
I get it that stata has a system that counts days from 1960 onwards, but what I don't get is that it suddenly interprets these days as months when I want to convert the variable......
Help me out please...
(I need the data to be a suitable monthly time-series so that I can perform dfuller test. It won't do that at the moment because I've got a 'daily time series with gaps')
Thanks in advance
Comment