type mismatch

type mismatch

by Caitlin -
Number of replies: 3

Hi, I'm having trouble figuring out why I keep getting the error "type mismatch" with this command:
. replace foundonstreet = 1 if wherefound == "Street"
type mismatch
r(109);

In reply to Caitlin

Re: type mismatch

by Mariya Samoylova -

Did you write

generate foundonstreet = "0" ?

That denotes foundonstreet as a string; removing "" will make it numeric.

 

In reply to Caitlin

Re: type mismatch

by Tiffany -

The error message type mismatch r(109) means that in an expression, you attempted to combine a string and numeric subexpression in a logically impossible way.  When you generated the new variable foundonstreet, make sure there are no "" around 0. As Mariya said, that denotes foundonstreet as a string rather than numeric variable.