Good morning,

I would like to know how to split a local that is too long (for some purpose) into a couple of shorter locals? I guess there is some macro extended function, but the help of the macro extended functions is a bit opaque, I read it for more than half an hour, and still could not figure out how to do this.

The motivation for the question is from the task in this thread here:

https://www.statalist.org/forums/for...other-variable

I want to check whether any value of var1 appears anywhere in var2. So my solution is to :

Code:
 . levelsof var2, local(second)  separate(,)

28,41,42,547  

. gen coincide = inlist(var1,`second')
this works for the small data example because there are only 4 distinct values in var2, but if there were 5000 distinct values, I would need to split my local 'second' into locals that are shorter than 254 elements, because this is the maximum arguments that the -inlist- function can take.

So what are the macro extended functions relevant here, and how do I use them?

In short imagine that I have a local constituting of 5000 elements, and I want to split it in a couple of locals all shorter than 254 elements?