Quantcast
Channel: Statalist
Viewing all articles
Browse latest Browse all 73334

How to only keep those observation numbers that exist in two separate columns

$
0
0
I have matched data, i.e. data that matches individual in column 1 to individuals in column 2. As such, these can be viewed as a bipartite graph. I only wish to keep those individuals that exist in both columns. An example data set is :

Code:
clear
column1 column2)
1 2
1 3
1 4
4 1
4 2
4 3
3 1
end
I want to delete observations that don't appear in both columns. In this case, 2 only appears in column 2- thus I want to delete those all those observations where 2 appears. Any help is appreciated.

Viewing all articles
Browse latest Browse all 73334

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>