I have several lists containing variables that vary in length. For each of these lists, I want to create a new list for every possible unique (nonempty) subset.
For example, for a list "a b c" I want to creat the lists "a", "b", "c", "ab", "ac", "bc", "abc". This is easy for a small list, but I want this to be as general as possible for lists at least up to length 6. I know that I could write a complicated nested loop in which I would "atomize" the original list and rebuild new lists for each i<="number of elements in original list" (and then this would not be a Stata question, but a general programming exercise), but maybe there is a better and direct way for me to proceed here with a function in Stata I am not aware of?
For example, for a list "a b c" I want to creat the lists "a", "b", "c", "ab", "ac", "bc", "abc". This is easy for a small list, but I want this to be as general as possible for lists at least up to length 6. I know that I could write a complicated nested loop in which I would "atomize" the original list and rebuild new lists for each i<="number of elements in original list" (and then this would not be a Stata question, but a general programming exercise), but maybe there is a better and direct way for me to proceed here with a function in Stata I am not aware of?
Comment