Statalist The Stata Listserver


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

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


From   "Scott Merryman" <[email protected]>
To   <[email protected]>
Subject   st: RE: Behaviour of -tokenize- shouldn't it drop the parsing character?
Date   Wed, 4 Oct 2006 17:30:56 -0500

[P] tokenize does address this:  "...nonspace parsing character are saved in
the number macros together with the tokens being parsed..."

Here is one way around this problem:

macro drop _all
 local test 1 | 2 | 3
 local foo : subinstr local test "|" " ", all
 tokenize "`foo'" 
 mac dir

Scott


> -----Original Message-----
> From: [email protected] [mailto:owner-
> [email protected]] On Behalf Of David Elliott
> Sent: Wednesday, October 04, 2006 4:45 PM
> To: [email protected]
> Subject: st: Behaviour of -tokenize- shouldn't it drop the parsing
> character?

<snip>

> *Should* tokenize be returning the parsing character as positional
> macros in addition to the parsed text?  This appears to be the
> behaviour regardless of the parsing character chosen although the
> default parsing on " " does not do this.  It is not impossible to work
> around (one could use a while "`i'" != "" { loop and increment `i' by
> 2 ), but is contrary to how I would expect the command to work.
> Doubtless the Stata mavens have some good reason for it working in
> this manner, but I fail to see how having a parsing character in the
> positional macro is useful.  The -help tokenize- is silent on this
> matter.  Is there something I am not grasping here or is there a
> better way of doing this?
> 
> Many thanks.
> 
> --
> David Elliott


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