The OBD Test Protocol requires certain conditions to be met to clear any former stored codes that have been fixed.
It is 90% of the time assumed that it is mileage that clears the codes...but its not. It requires specific driving conditions for specific time intervals. A person’s “driving cycle” may not fulfill all of the required OBD II driving cycle requirements.
See the chart below for the conditions & timing required to complete an OBD II FTP (federal test protocol) driving cycle. Try to find a route that you can take that will allow you to accomplish all the things required. You can see in total it only takes approx 27-30 minutes to complete an OBD II driving cycle: