> -----Original Message-----
> From: [email protected] [mailto:owner-
> [email protected]] On Behalf Of David Elliott
> Sent: Wednesday, October 04, 2006 8:33 PM
> To: [email protected]
> Subject: Re: st: RE: Behaviour of -tokenize- shouldn't it drop the parsing
> character?
>
> 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?).
>
Another thought: can this problem be avoided by using an -ifcmd- statement
to ignore the positional macros with "|". Something like this:
local test 1 2 3 | 4 5 | 6 7 8 | 9
tokenize "`test'", p(|)
while "`1'" != "" {
if "`1'" != "|" {
disp "`1'"
}
macro shift
}
Scott
*
* 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/