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

From |
"Nick Cox" <n.j.cox@durham.ac.uk> |

To |
<statalist@hsphsun2.harvard.edu> |

Subject |
st: RE: AW: How to make ID as 01 instead of 1 |

Date |
Mon, 14 Dec 2009 13:23:40 -0000 |

Similarly, the function -string()- takes a numeric format as argument, which could be a leading zero format. Nick n.j.cox@durham.ac.uk Martin Weiss You cannot -replace- the numeric variable because -replace- cannot promote the data type to -string-. Just create a new variable, then: gen newx="0"+string(x) You could also -format- the numeric variable -format x %02.0f- to achieve a similar effect, without changing the actual contents of the variable... Quang Nguyen 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". * * 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/

**References**:**st: How to make ID as 01 instead of 1***From:*Quang Nguyen <quangn@gmail.com>

**st: AW: How to make ID as 01 instead of 1***From:*"Martin Weiss" <martin.weiss1@gmx.de>

- Prev by Date:
**st: predict, rs option for probit?** - Next by Date:
**st: test after iv** - Previous by thread:
**st: AW: How to make ID as 01 instead of 1** - Next by thread:
**[no subject]** - Index(es):

© Copyright 1996–2015 StataCorp LP | Terms of use | Privacy | Contact us | What's new | Site index |