Equivalent function R "% in%" for Stata

Is there an equivalent function "% in%" from R for Stata?

+4
source share
3 answers

As already mentioned, it's hard to say what you need from the question. inlist() may work, or it may not match the setting.

I find the features of the Stata macro lists invaluable. Store your list in a macro (local or global), and then a set of useful commands :

 local list abcdde local search c local search_in_list : list search in list di `search_in_list' 

They can be calculated on the fly:

 if `: list search in list' { actions if true } 
+4
source

Stata does not offer the same flexible tool, but the inlist will cover the main operation that you can search for, as in count if inlist(country,"FR","US","DE") .

+2
source

Listing is one way, you can also just treat rhs as a string and treat lhs as a regular expression, use regexm ()

+1
source

Source: https://habr.com/ru/post/1340964/


All Articles