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 22:33:06 -0300

Thank you, Scott - I didn't have access to the paper manual and -help
tokenize- omitted that little fact.  Your solution would work with my
first example but for more complex strings like my example: 1 2 3 | 4
5 6| 7 8 | 9 where I want the parse to give me the groups separated by
the "|" as tokens - not the individual items within the groups (that
comes later).  For now I am going to do the following:

local test 1 2 3 | 4 5 6| 7 8 | 9
tokenize `"`test'"' , parse("|")
local i = 1
while `"`i'"' != "" {
   tokenize `"`i'"'
   local j = 1
   while `"`j'"' != "" {
       do something with j
       local ++j
       }
   local ++i
   macro shift  // this advances over the token and allows i to progress 1,2,3
   }


I still think tokenize *should* have a noparsechar option that does
not save the parsing characters (Stata, are you listening?).

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