0
votes

The Stata file I am using has a Date column. I am not sure whether the data is already in Stata data format. If not, please provide some guideline.

As a neophyte, I tried the following code

. generate date2 = date(Date,"DMY")
type mismatch

The Date column entries look like the following

31jan1995
28feb1995
31mar1995
30apr1995
...

More info: Type=long Format=%d

1
I think you mean "date format" not "data format". - Nick Cox

1 Answers

1
votes

The Date variable (not column in Stata terms) is already a numeric variable formatted appropriately as a daily date.

So, the date() function complains because it expects a string variable name or string expression as first argument.

The only other noteworthy detail is that %d is no longer documented routinely as a daily date display format; in recent Stata versions, %td is the documented equivalent.