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

Remove a row of variables in a non-survey data set

$
0
0
My non-survey dataset looks like this
ID Location
1 AICU
1 BICU
1 NICU
1 4W
1 4W
1 4W
1 4W
1 4W
2 5E
2 5E
2 5E
3 NICU
3 6E
3 6E

I want to remove any row of ID that has one instance of either AICU/BICU/NICU in the location variable

In addition to removing the row that has ID 1 and Location AICU ( first example) , I want to remove the 4th example too as ID is 1 and the ID had either one instance of AICU/BICU/NICU
In other words, I want to retain only ID's that have never been even once in AICU/BICU/NICU.

The sample size is around 50,000, so cannot do it manually.

If the removal process is carried out correctly, the resultant dataset would look like this
ID Location
2 5E
2 5E
2 5E

I suspect it has to be a looping code, but can't seem to wrap my mind on how to start. I appreciate any insight.
Thanks for your time


Viewing all articles
Browse latest Browse all 73407

Latest Images

Trending Articles



Latest Images

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