Quantcast
Channel: Statalist
Viewing all articles
Browse latest Browse all 72786

Data conversion from weekly to daily (Date mismatch)

$
0
0
Hi. I am using Stata 13 and have a question about the “collapse” command and Stata date formatting.
I have a daily time series from January 1971 up to nowadays. Data is from Monday to Friday (weekends omitted). I am trying to convert my daily time series into weekly ones with the object for Stata selecting the last day of the week (which is Friday in my case).

So I used:
gen dw=wofd(date)
collapse (first) var1, by (dw)
format %twMon_DD,_CCYY dw

I discovered that the calendar days are not matching up. Stata has converted dates correctly until December 1971. In that month, it should have picked the 3rd, 10th, 17th, 24th, and 31st dates. But for some reason Stata ignored the 31st (which was Friday and I have data for that day), created the new date January 1st 1972 and assigned the value from December 31 to January 1st.
From that point downward everything got mismatched i.e. Stata assigned the wrong values to wrong days of the week.

I also tried to use “last” option for “collapse” command with the same result.
Has somebody else been encountered with such a problem? I would appreciate any suggestion how to resolve this issue.

Thank you in advance

P.S. I have attached my data file

Viewing all articles
Browse latest Browse all 72786

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>