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" <smerryman@kc.rr.com>
To   <statalist@hsphsun2.harvard.edu>
Subject   st: RE: Behaviour of -tokenize- shouldn't it drop the parsing character?
Date   Wed, 4 Oct 2006 20:41:06 -0500

> -----Original Message-----
> From: owner-statalist@hsphsun2.harvard.edu [mailto:owner-
> statalist@hsphsun2.harvard.edu] On Behalf Of David Elliott
> Sent: Wednesday, October 04, 2006 4:45 PM
> To: statalist@hsphsun2.harvard.edu
> Subject: st: Behaviour of -tokenize- shouldn't it drop the parsing
> character?
> 
> I want to tokenize groups of numbers separated by the "|" character:
> e.g.: 1 2 3 | 4 5 6| 7 8 | 9 so that I have each group in a positional
> macro
> _1 = 1 2 3, _2 = 4 5 6 ...  However, I have found that tokenize does
> not behave as I expected.

I misread what the actual problem was.  Here is one way to get the space
separated positional macros:

local test 1 2 3 | 4 5 | 6 7 8 | 9

local test : subinstr local test " " ",", all 
local test : subinstr local test "|" " ", all 
local count : word count `test'
tokenize "`test'"
forv i = 1/`count' {
	local `i': subinstr local `i' "," " ", all 
}
mac dir


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/



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