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

st: Data manipulation: Pairs of variables

From   "Falko Juessen" <[email protected]>
To   [email protected]
Subject   st: Data manipulation: Pairs of variables
Date   Wed, 27 Jul 2005 17:58:08 +0200

Dear Statalisters,

I have a question concerning data manipulation in Stata.

Please consider a stylized version of my dataset:

var1	var2	var3
1		2		223
1		3		12
2		1		7544
2		3		7864
3		1		434
3		2		12334

You can think of var1 and var2 as identifying different regions in a
country and var3 could measure migration between region pairs, for example
223 persons migrate from 1 to 2. There are three regions. Migrating within
the same region is not possible, that is why there are no (1,1),(2,2) or
(3,3) observations for var1 and var2.

I would like to generate a variable var4 which should look like (or
similarly coded):

var4 counts the region PAIRS: (1,2) and (2,1) are one pair, (1,3) and
(3,1) are the second pair, and (2,3) and (3,2) are the third pair.
Unfortunately, I am not sure how to do this.

My plan is to use var4 to calculate the net migration volume between
regions, which means I want to calculate:

I wonder if I have to generate sub-datasets and use the -cross- command.
Is there perhaps an easier way to generate var4? Or is the variable var4
not necessary at all to calculate the net migration?

Thank you very much in advance,

*   For searches and help try:

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