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.
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