Statalist


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

st: RE: string variable


From   "Kieran McCaul" <Kieran.McCaul@uwa.edu.au>
To   <statalist@hsphsun2.harvard.edu>
Subject   st: RE: string variable
Date   Fri, 28 Aug 2009 14:59:56 +0800

...

How about 
keep if substr(bankname,1,8) == "Fidelity" | bankname == "Citibank"

______________________________________________
Kieran McCaul MPH PhD
WA Centre for Health & Ageing (M573)
University of Western Australia
Level 6, Ainslie House
48 Murray St
Perth 6000
Phone: (08) 9224-2701
Fax: (08) 9224 8009
email: Kieran.McCaul@uwa.edu.au
http://myprofile.cos.com/mccaul 
http://www.researcherid.com/rid/B-8751-2008
______________________________________________
If you live to be one hundred, you've got it made.
Very few people die past that age - George Burns


-----Original Message-----
From: owner-statalist@hsphsun2.harvard.edu
[mailto:owner-statalist@hsphsun2.harvard.edu] On Behalf Of Sue
Sent: Friday, 28 August 2009 11:38 AM
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/



© Copyright 1996–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index