Hi,

With the dataset similar to the one listed below, I am trying to find whether main_var contains the corresponding string from search_var.
I tried doing this with strpos, nooccur, and moss. But my understanding is that substring to be searched cannot be a variable name.

The following post comes close but, in that, multiple variables are being searched for a fixed string.
https://www.statalist.org/forums/for...ltiple-strings

I am sure I am missing something rather simple. I would really appreciate it if someone can help me out. Thanks in advance.

Code:
* Example generated by -dataex-. To install: ssc install dataex
clear
input str11 main_var str4 search_var float has_search_var
"value one"   "one"  1
"value two"   "two"  1
"value three" "two"  0
"value four"  "four" 1
end

regards
Swanand