Statalist


[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

Re: st: RE: find-replace in stata


From   "Dalhia Mani" <dalhia.mani@gmail.com>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: RE: find-replace in stata
Date   Thu, 23 Aug 2007 10:53:36 -0500

Thanks so much. This list is absolutely great.
Dalhia

On 8/22/07, Nick Cox <n.j.cox@durham.ac.uk> wrote:
> In Stata I would suggest -- subject to the advice at the end --
>
> replace company_name = subinstr(company_name, "ltd.", "ltd", .)
>
> This is literal. You might need also
>
> replace company_name = subinstr(company_name, "Ltd.", "Ltd", .)
>
> and perhaps other variants.
>
> This finds and replaces the substring specified whereever it exists. More
> paranoid code would do this
>
> replace company_name = reverse(subinstr(reverse(company_name), ".dtl", "dtl", 1))
>
> and so forth to be sure of trapping only the first such string counting backwards.
>
> See also help for -subinstr()- and more generally for string functions.
>
> However, don't -replace- your variable at all. Use -clonevar- to
> create a clone, modify that, and then check to see what you
> have done.
>
> Nick
> n.j.cox@durham.ac.uk
>
> Dalhia Mani
>
> > hi, I have a fairly simple problem for which I am sure STATA has an
> > easy solution but I can't seem to find it.  I am hoping  you can help
> > me.
> >
> > Here is what I need to do:
> > I have a string variable called company_name which has names like
> > "microsoft ltd."
> > What I need to do somehow remove the dot at the end of the "ltd." in
> > all cases where a dot appears at the end of the ltd.  The equivalent
> > in excel is a global find-replace.  I tried "recode" but that seems to
> > work only for numeric variables.
> >
> > How do I do this?
> >
>
> *
> *   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/
>


-- 
Dalhia Mani
Department of Sociology
University of Minnesota
Office: 1052 Social Sciences
Phone: 612 718 5557
email: dalhia.mani@gmail.com
--------------------------------------------
Snail Mail Address:
1052, Social Sciences
267 19th Avenue South
Minneapolis MN 55455
*
*   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