[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]
st: RE: recoding variables in order to merge datasets
> 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
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.
* For searches and help try: