Supposing I have a local or global macro with a set of numeric or string values, so a list, and I wish to use them in Mata as a vector. Is there a simple way to do that, perhaps with a Mata analogue of -word count- which would allow me to formulate a -for-/-foreach- loop?
To make this concrete, here's a example.
This bit of code does what I want it to do, and -want- is correct. Is there a better or more direct approach to this task? I have considered -ustrsplit()- but this can't work in all situations, such as in the above when a space can both delimit the list and be present within each item.
To make this concrete, here's a example.
Code:
local have_list `" "This is" "my list" "to" "test" "' mata want = J(1, 0, "") foreach item of local have_list { mac list _item mata: item = st_local("item") mata: want = want , item } mata: want
Comment