Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at

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

st: Convert string with special characters to lower case

From   Jorge Eduardo Pérez Pérez <>
To   <>
Subject   st: Convert string with special characters to lower case
Date   Wed, 25 Apr 2012 13:54:56 -0400

I have some text in Spanish that includes accents and special
characters in uppercase, e.g
and I would like to convert it to proper case. Stata 12.1 in a Windows
machine doesn't do it correctly: if I apply -proper- to the previous
text, I get:
"ZuÑiga", "RodrÍguez"

The correct conversion could be achieved by getting the positions of
the accented characters, replacing the accented versions of the
characters with their unaccented versions using -subisntr- or -regex-,
converting it to proper case, and then putting the accents back using
the previous positions and -substr-. However, this would require some
loops over observations and over characters. It seems terribly
cumbersome and inefficient for large datasets.

Does anyone know a better way to achieve this?

Thank you,
Jorge Eduardo Pérez Pérez

PD: I am hoping that the Spanish characters make it through the plain
text encoding and are displayed correctly when you get this e-mail. If
not, then probably this e-mail will not make much sense, specially to
speakers of languages without special characters. Sorry about that.

*   For searches and help try:

© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index