Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.
From | Nick Cox <njcoxstata@gmail.com> |
To | "statalist@hsphsun2.harvard.edu" <statalist@hsphsun2.harvard.edu> |
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 njcoxstata@gmail.com On 7 January 2014 02:28, Benjamin Villena <benjamin.villena.r@gmail.com> 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/