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: String problem


From   Nick Cox <[email protected]>
To   "[email protected]" <[email protected]>
Subject   Re: st: String problem
Date   Tue, 18 Mar 2014 15:27:31 +0000

On this example, the problem is trailing "*/". That could be fixed with

replace ref = subinstr(ref, "*/", "", .)

if "/*" never occurs otherwise, or with

replace ref = substr(ref, 1, length(ref)-2) if substr(ref,-2, 2) == "/*"

more conservatively.
Nick
[email protected]


On 18 March 2014 15:22, Carlos Avellaneda Suárez
<[email protected]> wrote:
> Dear Statalist,
>
> I have to merge several datasets where my key variable is a string
> variable, with no specific rule about the length of each string
> observation. The problem is that there are some characters (i.e. */)
> that are mistakenly added at the end of some observations. I would
> like to know how to eliminate those characters because they are
> causing me troubles when I merge the datasets. I am sorry if this is a
> basic question, but I have never faced this problem before and I don't
> know how to solve it.
>
> Here is an example of what I have:
>
> ref
> WG1855515
> WG1855515*/
> WIN18555R15
> WIN18555R15*/
> PCAV
> PCAV*/
> HKK20560R16
> HKK20560R16*/
>
> Here is what I would like to obtain:
>
> ref
> WG1855515
> WG1855515
> WIN18555R15
> WIN18555R15
> PCAV
> PCAV
> HKK20560R16
> HKK20560R16
>
> Any help is highly appreciated. Best regards.
> Carlos
> *
> *   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