Another reason for knowing how to do this:
My truck occasionally has the check engine light come on, and throws a code for the EGR. CA emissions test will fail me automatically if it reads the stored code.
Twice in the last 4 years before getting tested, I disconnect the battery and clear the codes, and she passes no problem. This last time, the CEL came on again on the way home from the test.
I suppose one of these days I oughtta get under the hood for real...