Statalist The Stata Listserver


[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

Re: st: RE: Behaviour of -tokenize- shouldn't it drop the parsing character?


From   "David Elliott" <[email protected]>
To   [email protected]
Subject   Re: st: RE: Behaviour of -tokenize- shouldn't it drop the parsing character?
Date   Wed, 4 Oct 2006 23:15:45 -0300

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
  }

Thanks again,

DCE
*
*   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/



© Copyright 1996–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index