Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

Re: st: RE: two-digit string variables


From   Alejandro Delafuente <alejandro.delafuente@st-antonys.oxford.ac.uk>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: RE: two-digit string variables
Date   Thu, 9 Jun 2005 18:25:07 +0100 (BST)

Thanks Nick!
In message <6.2.1.2.2.20050609092944.048a3e00@postoffice9.mail.cornell.edu> 
statalist@hsphsun2.harvard.edu writes:
> Yet another approach:
> 
> replace x = string(real(x),"%02.0f")
> 
> 
> 
> --Nick Winter
> 
> 
> At 08:00 AM 6/9/2005, you wrote:
> >replace x="0"+x if length(x)==1
> >
> >David
> >
> >-----Original Message-----
> >From: Alejandro Delafuente
> >[mailto:alejandro.delafuente@st-antonys.oxford.ac.uk]
> >Sent: 09 June 2005 12:44
> >To: statalist@hsphsun2.harvard.edu
> >Subject: st: two-digit string variables
> >
> >
> >Hi statalisters,
> >I have a string variable with two-digit and one-digit values. How can I tell
> >Stata to place zeros before those one-digit values so that I end up with two
> >digits in all cases always. For instance,
> >x          x(desired)
> >34           34
> >3            03
> >25           25
> >
> >Many thanks for any help!
> >
> >
> >*
> >*   For searches and help try:
> >*   http://www.stata.com/support/faqs/res/findit.html
> >*   http://www.stata.com/support/statalist/faq
> >*   http://www.ats.ucla.edu/stat/stata/
> 
> --------------------------------------------------------
> Nicholas Winter                           607.255.8819 t
> Assistant Professor                       607.255.4530 f
> Department of Government              nw53@cornell.edu e
> 308 White Hall            falcon.arts.cornell.edu/nw53 w
> Cornell University
> Ithaca, NY 14853-4601 
> 
> *
> *   For searches and help try:
> *   http://www.stata.com/support/faqs/res/findit.html
> *   http://www.stata.com/support/statalist/faq
> *   http://www.ats.ucla.edu/stat/stata/
> 

-- 
Alejandro de la Fuente
QEH/Department of International Development
Oxford University
*
*   For searches and help try:
*   http://www.stata.com/support/faqs/res/findit.html
*   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