Statalist


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

st: RE: How to convert string into lower case except the first letter


From   "Martin Weiss" <[email protected]>
To   <[email protected]>
Subject   st: RE: How to convert string into lower case except the first letter
Date   Tue, 2 Feb 2010 19:44:50 +0100

<>

*******
clear*

input str9 country
ARGENTINA
BELGIUM
end

gen cntry=substr(country, 1, 1)+ lower(substr(country, 2, .))
list, noo

*******


HTH
Martin

-----Original Message-----
From: [email protected]
[mailto:[email protected]] On Behalf Of Mike Kim
Sent: Dienstag, 2. Februar 2010 19:40
To: [email protected]
Subject: st: How to convert string into lower case except the first letter

Dear all,

I would like to convert a string variable into lower case except the first 
letter. That is:
from ARGENTINA to Argentina
from BELGIUM to Belgium
....

Using "lower" converts every letter into lower case: gen 
cntry=lower(country)

country
ARGENTINA
BELGIUM
....

Thank you in advance.
Mike.

*
*   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–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index