Bookmark and Share

Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down at the end of May, and its replacement, statalist.org is already up and running.


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

st: AW: Writing a loop to change a letter in a string variable


From   "Martin Weiss" <martin.weiss1@gmx.de>
To   <statalist@hsphsun2.harvard.edu>
Subject   st: AW: Writing a loop to change a letter in a string variable
Date   Wed, 11 Aug 2010 17:26:49 +0200

<> 


Stata applies the string function to all observations automatically, so a
loop is not rquired at all here:


*************
clear*
inp str10 name
JimÉnez
end

l

replace name=lower(subinstr(name, "É", "E",.))
l
*************



HTH
Martin


-----Ursprüngliche Nachricht-----
Von: owner-statalist@hsphsun2.harvard.edu
[mailto:owner-statalist@hsphsun2.harvard.edu] Im Auftrag von Martin Pszczola
Gesendet: Mittwoch, 11. August 2010 17:22
An: statalist@hsphsun2.harvard.edu
Betreff: st: Writing a loop to change a letter in a string variable

Hi;

   I am trying to edit my data, which happens to include a lot of Spanish
accents. For example, I have a variable named "apellido" with string data
like "JimÉnez" and I want to find an efficient way to change that to
"Jimenez". Can anyone suggest a loop that would make such a change over the
whole variable? Also, how can one change from capital letters to lower case,
i.e. "Jimenez" to "jimenez". Thank you.
*
*   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   |   Site index