Bookmark and Share

Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down on April 23, and its replacement, statalist.org is already up and running.


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

Re: st: How to make ID as 01 instead of 1


From   Hưng Đoàn Quang <dqhung278@gmail.com>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: How to make ID as 01 instead of 1
Date   Thu, 25 Feb 2010 23:15:05 +0700

You can try to use the following command
tostring ID, replace
gen strID = "0" + ID

It is hopeful that can help you.

Hung,

Full name: Doan Quang Hung
Lecturer: Stata, SPSS, Fundamental Statistics and CsPro
Mobile: 84 (0) 982 609 551


On Mon, Dec 14, 2009 at 7:44 PM, Quang Nguyen <quangn@gmail.com> wrote:

> Dear all:
>
> Can you show me how I can generate ID in the following manner: 01,
> 02..... instead of 1, 2, 3...?
>
> From the original data, I have ID in the form of 1, 2, ...... I then
> use the following commands:
>
> tostring ID, replace
> replace x = "01" if x=="1"
>
> There was a message "type mismatch".
>
> Any help is appreciated.
>
> Sincerely yours,
>
> Quang
>
>
> --
> "My father gave me the greatest gift anyone could give another person,
> he believed in me." - Jim Valvano
> *
> *   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   |   Site index