Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Destring variable

    Hi there Stata users,

    I am trying to merge two datasets using the date as the variable to be merged on. However, in one file the date is an 'int' type while in the other file the date is a 'string' variable which causes an error in merging as Stata will only merge if both variables are of the same type. I have tried to destring the date but this is without success. Can anyone help me out with this?

    Kind regards,

    Tony

  • #2
    you don't say what you mean by "without success" - please read the FAQ for help in asking questions

    my guess is that your variable is primarily a numeric variable but there are some non-numeric characters; in that case, try
    Code:
    ta varname if real(varname) == .
    to see which characters are "causing" the problem; then you can use either the "force" option or the "ignore" option to -destring- ; see the help file

    forgot to say that you should subtsitute your real variable name where I have written "varname" (more than one place)

    Comment

    Working...
    X