Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: st: Macro parsing question


From   Nick Cox <[email protected]>
To   "[email protected]" <[email protected]>
Subject   Re: st: Macro parsing question
Date   Tue, 7 Jan 2014 02:46:17 +0000

You can go

local X1 = substr("`X'", 1, strpos("`X'", "X") - 1)
local X2 = substr("`X'", strpos("`X'", "X") + 1, .)

or

gettoken X1 X : X, parse("X")
gettoken sep X2 : X, parse("X")

Nick
[email protected]


On 7 January 2014 02:28, Benjamin Villena <[email protected]> wrote:
> Dear Statalist,
>
>  Suppose I have a macro X of this form:
>
>  local X part_oneXpart_two
>
>  How could I generally obtain two macros taking values "part_one" and
> "part_two"?
>
>  So, in general, I need to count characters until the "X" and obtain a
> word from the first character until the one just before "X". Then, I
> need to obtain a word from the character just after "X" until the end.
>
>  Thanks
>
>  Benjamín
>
> *
> *   For searches and help try:
> *   http://www.stata.com/help.cgi?search
> *   http://www.stata.com/support/faqs/resources/statalist-faq/
> *   http://www.ats.ucla.edu/stat/stata/

*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/faqs/resources/statalist-faq/
*   http://www.ats.ucla.edu/stat/stata/


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index