You are noticing the way TAQ data designates canceled quotes and invalid quotes. There is no easy solution and everyone needs to deal with this in some manner when using TAQ data and 'clean' the data for their uses.
I recommend that you start by reading items Joel Hasbrouck at NYU has posted on his website about http://pages.stern.nyu.edu/~jhasbrou/ on empirical market microstructure research.
Also, Craig Holden at Indiana has posted his code on TAQ at his homepage, https://kelley.iu.edu/cholden/.
You may also want to look at our NBBO programs, as described in another thread 'TAQ NBBO'.
Also see Chapter 10 of Using SAS in Financial Research, by E.Boehmer, J.Broussard & J.Kallunki