Erica Seiguer
>
> I am trying to merge two datasets which have the same variable coded
> differently in each.
>
> In dataset 1, the variable is 6 digits, with the first
> digit being a zero.
>
> in dataset 2, the same variable is 5 digits, and the first
> digit (which
> should be a zero) as been truncated.
>
> Does anyone know how to add a zero to the variable in the
> second dataset?
This is a variant on a question asked yesterday on
leading zeros.
If your variables are both numeric, then whether or
not a leading zero is shown is a matter of display
format and should not affect comparison.
If your variables are both string, then prepending a zero
is a -replace-
. replace myvar = "0" + myvar
If one variable is numeric and another string, then
convert one or the other. -destring- is one canned
solution in official Stata to convert string to numeric.
Nick
[email protected]
*
* 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/