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: How do I split a string variable without spaces by capital letters?


From   Nick Cox <[email protected]>
To   "[email protected]" <[email protected]>
Subject   Re: st: How do I split a string variable without spaces by capital letters?
Date   Mon, 19 Aug 2013 19:30:28 +0100

Thanks for this, but please note my top line. -moss- (SSC) is to be
preferred here, I think.
Nick
[email protected]


On 19 August 2013 18:16, Andrew Dickens <[email protected]> wrote:
> Thanks for the tip about -moss-. Much appreciated to both Robert and Eric.
>
> Nick, thanks for clarifying. I'm relatively new to this, and your
> explanation makes things much clearer. Noted for future reference.
>
> Best,
> Andrew
>
>
> Quoting Nick Cox <[email protected]>:
>
>> I like -moss- too for a variety of reasons.
>>
>> It's important to understand, however, why the approach with -split-
>> does not work. -split- expects that strings can be parsed into
>> substrings using separators. Part of the definition of separators is
>> that they can thrown away, but that's not true here.
>>
>> Independently of that, the reason that -split- did nothing to the
>> original variables is that it was looking for literal strings such as
>>
>> "upper(a-z)"
>>
>> as separators, and did not find any examples. The syntax is not
>> illegal, but it's a long way from doing what you wanted, as -split-
>> does not understand regular expressions and won't apply functions to
>> them either.
>>
>> split v1, p(`c(ALPHA)')
>>
>> would have chopped whenever it saw any of A ... Z but those upper-case
>> letters would have been thrown out too.
>>
>> Nick
>> [email protected]
>>
>
> *
> *   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