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

st: combine 3 numeric vars. to create 1 unique id. var

From   "Nick Cox" <[email protected]>
To   <[email protected]>
Subject   st: combine 3 numeric vars. to create 1 unique id. var
Date   Tue, 13 Aug 2002 13:38:08 +0100


I need to create a unique id variable by combining three
different numeric variables viz. "district", "house" and
"person". "District" has been entered as a four digit
number code (1000 to 1500). Each "District" has "house"s
numbered 1 to 150 (no zero in front) and each "house" has
"person" with numbers ranging from 1 to 12 (again no zero
in front). I need the uniqe id variable to merge this
dataset with another data file having other information
about these particular people.

As members may have figured out by now...I am new not only
to this list but to Stata too. I have tried looking for
help elsewhere...but the lack of Zeros in "house" and
"person" is giving me problems. Please help...

>>> Try

gen str1 id = ""
replace id = string(district) + string(house,"%03.0f") +

[email protected]

*   For searches and help try:

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