Hi there!
I'm working with the Census county adjacency file (https://www.census.gov/geographies/r...adjacency.html) and want to keep only unique pairs; i.e. if county 1 and 2 are neighbors of each other, there are two observations that reflect that in the dataset ( (1, 2) and (2, 1) ) and I'd only like to keep one of those two observations. I've been trying to figure out how to do this with unique/distinct/tag(), to no avail.
For a simpler example, here's a short script that draws up a parallel dataset. If you look at the observations, you'll see half of them are "mirrored"; i.e. (B,A) = (1, 10) in row 1 and (10, 1) in row 10. I'd like to drop all "mirrored" observations.
Thanks!
Jake
I'm working with the Census county adjacency file (https://www.census.gov/geographies/r...adjacency.html) and want to keep only unique pairs; i.e. if county 1 and 2 are neighbors of each other, there are two observations that reflect that in the dataset ( (1, 2) and (2, 1) ) and I'd only like to keep one of those two observations. I've been trying to figure out how to do this with unique/distinct/tag(), to no avail.
For a simpler example, here's a short script that draws up a parallel dataset. If you look at the observations, you'll see half of them are "mirrored"; i.e. (B,A) = (1, 10) in row 1 and (10, 1) in row 10. I'd like to drop all "mirrored" observations.
Code:
clear
set obs 10
gen A = .
gen B = .
foreach i of numlist 1/10 {
replace A = `i' if _n == `i'
replace B = 11 - `i' if _n == `i'
}
sort B A
Jake

Comment