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

Re: st: Sorting Data

From   Russell Dimond <>
Subject   Re: st: Sorting Data
Date   Wed, 13 Nov 2002 11:44:50 -0600

The following seems to do what you want:

foreach i of numlist 1/5 {
gen withUS`i'=(vote`i'==vote`i'[1])
drop if country=="USA"
egen withUS=rsum(withUS1-withUS5)

Note that this depends on the USA being the first observation, as it is in your example. I added new variables rather than replacing vote1-vote5, but it would be easy enough to drop the original "vote" variables and rename the new ones.

Russell Dimond

At 06:16 PM 11/13/2002 +0300, you wrote:

I have the followig type of data that I want to sort in a way that I will

                Table 1 ( Year 1980)
Country     vote1   vote2   vote3   vote4   vote5 etc
USA          Y       N       Y       Y       A
Albania      N       Y       N       N       Y
Algeria      N       Y       Y       A       Y
Argentina    Y       N       Y       Y       Y

This data is of the UN general assembly voting on different resolutions and
it repeats itself for twenty years (1980 to 2000).

I want to constuct a variable for each country to represent the number of
times that
each country votes in line with the way USA votes. I am thinking of doing
the following:

In the first step to assign one (unit) to each vote that is the same as the
vote casted (or
not casted) by the USA and zero to each vote that differs with the US vote
on the same resolution.
Thus the data above would look like:

                Table 2 (Year 1980)
Country   vote1   vote2    vote3   vote4    vote5  etc
Albania    0       0         0       0       0
Algeria    0       0         1       0       0
Argentina  1       1         1       1       0

Thereafter I am thinking of making a row-wise summation to get a new
variable for the frequency that
a country voted in tune with the USA.

I'll very much appreciate if anyone can suggest to me a simple program for
reorganising the
data from Table 1 above to Table 2 and making the row-wise summation for
each country for each year.


A. F Mkenda
University of Dar es Salaam

*   For searches and help try:
*   For searches and help try:

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