There is no set number of miles that you have to drive to clear a check engine light. However, if the light is on due to a loose gas cap, it should reset itself after a few minutes of driving. If the light is on for another reason, it will likely stay on until the problem is fixed.