The procedure is painless and can be done during a routine annual visit or as part of a special medical checkup. A mammogram can detect cancer earlier than a biopsy.