Hello, I am facing trouble in Stata 14.2 when comparing a string variable across rows (i.e., observations). Consider the following toy data:
If I compare the values of the variables across the three observations, I face no problem for the numeric variable but get an error for the string variable. I run (and get):
Why am I getting the type mismatch error for the string variable?
Code:
clear all set obs 3 gen string_var = "a" gen numeric_var = 1
Code:
count if numeric_var == numeric_var[_n+1] == numeric_var[_n+2] 1 count if string_var == string_var[_n+1] == string_var[_n+2] type mismatch r(109);

Comment