Residency programs train doctors to work in a specific specialty, or field within medicine. For example, there are different residency programs for medicine, surgery, and psychiatry. In the US, the length of a residency program is different based on specialty. Residency in specialties like family medicine and psychiatry is usually three years long, but a residency program in neurosurgery (brain surgery) may be 7 years long.