Statalist


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

Re: st: RE: string variable


From   Sue <likecats@gmail.com>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: RE: string variable
Date   Fri, 28 Aug 2009 00:00:43 -0400

Hi,

I tried that already but it didn't work for some reason. I looked
through the list of string functions, but since itrim didn't work, I
didn't know any further.

sorry my post seems to have triggered so many out-of-office replies..


On Thu, Aug 27, 2009 at 11:52 PM, Howard Lempel<HLempel@brookings.edu> wrote:
> Hi there,
>
> If the only issue is that there are too many spaces in your data (so "Fidelity Bank" is stored as "Fidelity          Bank", then the following should work:
>
> replace bankname = itrim(bankname)
>
> You might also want to look at other string functions. If you have leading or trailing blanks, you want -trim-.  You might also want -lower- to deal with cases.
>
> Hope this helps.
> Howie
> ________________________________________
> From: owner-statalist@hsphsun2.harvard.edu [owner-statalist@hsphsun2.harvard.edu] On Behalf Of Sue [likecats@gmail.com]
> Sent: Thursday, August 27, 2009 11:38 PM
> To: statalist@hsphsun2.harvard.edu
> Subject: st: string variable
>
> Dear all,
>
> I was trying to do some simple data management with a string variable.
> More specifically, I did:
>
> insheet using bankyears.csv, clear
> keep if bankname == "Fidelity Bank" | bankname == "Citibank"
>
> which dropped all observations. When I looked at the data, it turned
> out that the width of the single space between words was different (it
> was wider in stata than in my editor, if this makes sense) although it
> was still just one space. I've tried
>
> replace bankname = subinstr(bankname, " ", "", .)
>
> which didn't work. I could encode the variable then single out the
> numeric value of the observations that I want to keep, but I was
> wondering if there was a non-manual way around this. If anyone has
> advice on this, I'd appreciate it.
> *
> *   For searches and help try:
> *   http://www.stata.com/help.cgi?search
> *   http://www.stata.com/support/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/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/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