Here's another way (better) to do it:
. l Country vote?
Country vote1 vote2 vote3 vote4 vote5
1. Albania N Y N N Y
2. Algeria N Y Y A Y
3. Argentina Y N Y Y Y
4. USA Y N Y Y A
Initialise a counter:
. gen agreesUS = 0
We note empirically that USA is observation 4.
. forval i = 1/5 {
replace agreesUS = agreesUS + (vote`i' == vote`i'[4])
}
. l Country vote? agrees
Country vote1 vote2 vote3 vote4 vote5
agreesUS
1. Albania N Y N N Y
0
2. Algeria N Y Y A Y
1
3. Argentina Y N Y Y Y
4
4. USA Y N Y Y A
5
Nick
[email protected]
*
* For searches and help try:
* http://www.stata.com/support/faqs/res/findit.html
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/