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

st: concatenate, leading zeros


From   daphna <[email protected]>
To   [email protected]
Subject   st: concatenate, leading zeros
Date   Mon, 22 Mar 2004 15:23:11 -0800

Hello- I am pretty new to stata and would really appreciate some help with what seems like a pretty basic question.

I need to concatenate three variables into 1, and all three may have leading zeros.
Whenever I concatenate, the leading zero's are dropped.

To be clear...

If I have:

var1=01
var2=04956
var3=0906730

I would like to get a variable back that is: 01049560906730

This is not what I am getting: instead I am getting 14956906730.

I have formatted all my variables as string with the appropriate formats. For instance, for my variable 1, I have done format var1 %02s.

They all look fine, and retain their leading zero's individually, but not once I concatenate.

Any thoughts?

I really appreciate your help with this.


=====================================================================

Daphna Bassok

Research Assistant
Center For Research On Education Outcomes
Stanford University
Stanford, CA 94305

Phone: (650) 725-6169

=====================================================================

*
* 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–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index