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

st: RE: two-digit string variables

From   "David Harrison" <[email protected]>
To   <[email protected]>
Subject   st: RE: two-digit string variables
Date   Thu, 9 Jun 2005 13:00:32 +0100

replace x="0"+x if length(x)==1


-----Original Message-----
From: Alejandro Delafuente
[mailto:[email protected]]
Sent: 09 June 2005 12:44
To: [email protected]
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:

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