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

Re: st: recoding variables in order to merge datasets

From   Ernest Berkhout <>
Subject   Re: st: recoding variables in order to merge datasets
Date   Wed, 02 Jul 2003 15:42:23 +0200

At 15:21 2-7-2003, you wrote:

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?
I take it that both matchvars are string variables. Otherwise there would be no problem at all as the difference would be just in the formatting. If, as you suggest, in dataset 1 there is always a zero first, its more efficient to get rid of that one. This implies creating a str5 variable using the string finction substr(matchvar1,2,5). See -help substr-

Ernest Berkhout
SEO Amsterdam Economics
University of Amsterdam

Room 3.08
Roetersstraat 29
1018 WB Amsterdam
The Netherlands

tel.:+ 31 20 525 1657
fax:+ 31 20 525 1686
A statistician: someone who insists
on being certain about uncertainty

* For searches and help try:

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