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

Excluding countries that have been marked in a previous observation

$
0
0
Country Year Missing
A 2005 0
B 2005 0
C 2005 0
A 2004 0
B 2004 0
C 2004 1
A 2003 1
B 2003 0
C 2003 0
Dear Stata users,

above you can see a stylised version of my dataset. I generated a variable called "missing" in case a country did not report a value for this country year observation. My goal is simple: If a country(!) experienced a missing value at any point in time, all country year observations belonging to that country should be marked, so that I can exclude them from future calculations. In this example, I would want to exclude all countries but country B from further analyses (C has been flagged for 2004 and A for 2003, so only 3 observations would remain: country B in all 3 years).

I thought about: replace missing = 1 if... and then I don't know how to go on

So far, I generated another variable called "marker" that is equal to the country's name if missing == 1. I though about coding something like: replace missing = 1 if "Country A" part of marker. I would run this command for all countries in my dataset, but I don't know how to code "part of marker".


If anyone knows how to handle this situation and is willing to share this information, I would appreciate it a lot!

Looking forward to reading from you!

Viewing all articles
Browse latest Browse all 65055

Trending Articles



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