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]

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


From   "Martin Weiss" <[email protected]>
To   <[email protected]>
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: [email protected]
[mailto:[email protected]] Im Auftrag von Martin Pszczola
Gesendet: Mittwoch, 11. August 2010 17:22
An: [email protected]
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–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index