-tknz- from SSC puts a specified stub in front of
the default names 1, 2, 3, etc. Thus you can
tokenize into macros foo1, foo2, foo3, etc.
This is occasionally useful when you want
to work with the results of -tokenize-
and also another set of numbered macros.
Nick
[email protected]
David Elliott
> The example I gave didn't work properly - you can't tokenize after a
> tokenize without destroying the original set of positional macros you
> were looping over. The following better illustrates what I was trying
> to do:
>
> local test 1 2 3 | 4 5 6| 7 8 | 9
> tokenize `"`test'"' , parse("|")
> local i = 1
> while "``i''" != "" {
> local group`i' = "``i''"
> local ++i
> macro shift // this advances over the token and allows i
> to progress 1,2,3
> }
> local m = `i' - 1
> local i = 1
> forvalues i = 1/`m' {
> tokenize `group`i''
> local j = 1
> while "``j''" != "" {
> di "Group i=`i' is: `group`i'' and subitem j=`j' is: ``j''"
> local ++j
> }
> local ++i
> }
>
*
* For searches and help try:
* http://www.stata.com/support/faqs/res/findit.html
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/