Dear Statalisters,
this might be obvious for a more advanced Stata user but still I cannot manage to solve the issue. I would like to check for any observation whether or not the value of a certain variable is element of a local. To make things clearer I add a hypothetical example here:
Here, I want to pass all elements of local mylev as an argument to the inlist function. Clearly, something is not working the right way here as var3 takes on value 0 in any case. In practise, I would like to run a similar code on a much richer dataset with 7,816 distinct values captured in the local. So an additional question on my side is whether this exceeds the limit of possible arguments of inlist?
Any help is highly appreciated.
Thanks,
Roberto
this might be obvious for a more advanced Stata user but still I cannot manage to solve the issue. I would like to check for any observation whether or not the value of a certain variable is element of a local. To make things clearer I add a hypothetical example here:
Code:
clear all input id var1 var2 1 3 2 1 4 5 2 6 4 2 2 1 2 4 1 3 4 5 4 9 3 end levelsof var1, local(mylev) gen var3 = inlist(var2, `mylev')
Any help is highly appreciated.
Thanks,
Roberto

Comment