Budu Gulo
Budu Gulo

Reputation: 3

Stata Date-- type mismatch

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

Upvotes: 0

Views: 1140

Answers (1)

Nick Cox
Nick Cox

Reputation: 37208

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.

Upvotes: 1

Related Questions