Older Americans are having fewer heart attacks and surviving them longer than ever before.

For a study published in JAMA Open Network, researchers analyzed records of 4.3 million Medicare beneficiaries hospitalized for heart attacks from 1995 through 2014 in 5,680 hospitals across the country.

The number of people hospitalized declined by 38 percent over the period, 30-day mortality decreased by 38 percent, and recurrent heart attacks within a year declined by 28 percent.

The study also found changes in treatment over the period. The use of procedures like stents and catheters that clear narrowed or blocked arteries increased by 57 percent, and this reduced the need for coronary bypass surgeries, which decreased by 29 percent.

The improvements were apparent in whites and blacks, men and women, rich and poor.

“In the 1990s, we had the procedures, the beta blockers, the clot busters, but we were treating patients too slowly or not using the most effective medicines,” said the lead author, Dr. Harlan M. Krumholz, a cardiologist at Yale. “This was a period of intense focus on improving the quality of care, with help from many health systems and national organizations.”