Statalist


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

st: AW: Inserting a number into existing study ids


From   "Martin Weiss" <martin.weiss1@gmx.de>
To   <statalist@hsphsun2.harvard.edu>
Subject   st: AW: Inserting a number into existing study ids
Date   Wed, 4 Feb 2009 15:09:12 +0100

<> 



*************
clear*
input str10 var1
K04945
end
*
generate left=substr(var1, 1,2)
generate middle=0
generate right= substr(var1, 3,.)
egen new=concat( left middle right)
drop left middle right
list
*************



HTH
Martin


-----Ursprüngliche Nachricht-----
Von: owner-statalist@hsphsun2.harvard.edu
[mailto:owner-statalist@hsphsun2.harvard.edu] Im Auftrag von Polis, Chelsea
B.
Gesendet: Mittwoch, 4. Februar 2009 14:54
An: statalist@hsphsun2.harvard.edu
Betreff: 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/


*
*   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   |   What's new   |   Site index