How to solve the problem of “no observations” in Stata?

When regression, time series analysis and panel data analysis are carried out in Stata, the problem of “no observations” often appears, as follows:

This is the excel format data of the relevant time series of US Treasury bond interest rates from January 2009 to December 2017

When we import the excel file through the file import Excel spreadsheet menu in Stata and name the first line as a variable, we import the excel file into Stata

At this point, when we test the unit root of tb1yr (first, we need tsset date to define the time variable), we will encounter the problem of “no observations”

By querying the relevant websites and their information, we can find that the problem of “no observations” is not entirely due to the missing value of tb1yr or the character type value of the variable. The main reason is that although the date variable is an int or float variable, its data format is 1/1/2009, It does not conform to the traditional Stata data format about time and date

In order to solve this problem, many people on the Internet have put forward the method of dividing date, replacing, and converting date into “numerical variable”

DATE already numeric; No replace indicates that date is numeric and no conversion is needed

Many people on the Internet have adopted many methods, but they are not effective. What should we do to solve this problem

The author thinks that since the problem lies in date and the attribute of date can’t be changed by various means, it’s better to regenerate a variable t about date and endow it with numerical value to solve the problem

Because the date variable date or t does not participate in the actual regression or time series analysis process, but is a defined index variable. The solution process is as follows:

A completely numerical time variable is generated by Egen t = group (date), and then it is defined by tsset T. finally, the unit root test is carried out. It can be seen that the problem of “no observations” will not appear

In this case, the representation of T variable is as follows:

this article shares WeChat’s official account – Dr. PhD’s dry cargo (econometrics_ ABC)。

Similar Posts: