No. That doesn't mean you'll lose money if you do, but you probably will. It generally takes about 5 years for the appreciation on a home to make up for the heavy transaction costs, and since most residencies are 5 years or less, most residents lose money on a home.
The Case Against Resident Homeowners
Should I Purchase My Residence During Residency?
10 Reasons Residents Shouldn't Buy a House