I'm trying to figure out a way of delimiting elements of a local macro so that I can reference each element by their position in the macro. For example in the local macro list_1 below, by adding `" "' around the whole list and including "" around each element, Stata will recognize that "item 1" is the first element in the list and "item 2" the second element and so on.
loc list_1 `" "item 1" "item 2" "item 3" "'
loc n: word count `list_1'
forval i=1/`n' {
loc element `: word `i' of `list_1''
}
However, when you have list of elements contain "", as in the example below, Stata will not recognize those as a single element.
loc list_1 `" "inlist(var1,"a","b","c")" "inlist(var1,"e","f","g")" "'
What I would like is for Stata to recognize inlist(var1,"a","b","c") as the first element and inlist(var1,"e","f","g") as the second element in the list. Any ideas on how I maybe able to achieve that?