Something like the following should work:
gen new_id = substr(id,1,1) + "0" + substr(id,2,.)
-----------------------------------
Thomas J. Steichen
[email protected]
-----------------------------------
-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of Polis, Chelsea B.
Sent: Wednesday, February 04, 2009 8:54 AM
To: [email protected]
Subject: st: Inserting a number into existing study ids
Dear Statalisters,
I need to insert a zero between the first and second characters in a column of study IDs. For example, K04945 must become K004945. Any clues on how to achieve this?
Many thanks!
Chelsea
*
* 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/
CONFIDENTIALITY NOTE: This e-mail message, including any attachment(s), contains information that may be confidential, protected by the attorney-client or other legal privileges, and/or proprietary non-public information. If you are not an intended recipient of this message or an authorized assistant to an intended recipient, please notify the sender by replying to this message and then delete it from your system. Use, dissemination, distribution, or reproduction of this message and/or any of its attachments (if any) by unintended recipients is not authorized and may be unlawful.
*
* 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/