From NBER -
"Women who graduate from university are less likely than men to specialize in science, technology, engineering, or math (STEM). We use detailed administrative data for a recent cohort of high school students in Ontario, Canada, combined with data from the province's university admission system to analyze the dynamic process leading to this gap. We show that entry to STEM programs is mediated through an index of STEM readiness based on end-of-high-school courses in math and science. Most of the gender gap in STEM entry can be traced to differences in the rate of STEM readiness; less than a fifth is due to differences in the choice of major conditional on readiness. We then use high school course data to decompose the gap in STEM readiness among university entrants into two channels: one reflecting the gender gap in the fraction of high school students with the necessary prerequisites to enter STEM, and a second arising from differences in the fractions of females and males who enter university. The gender gap in the fraction of students with STEM prerequisites is small. The main factor is the lower university entry rate by men – a difference that is due to the lower fraction of non-science oriented males who complete enough advanced level courses to qualify for university entry. We conclude that differences in course-taking patterns and preferences for STEM conditional on readiness contribute to male-female differences in the rate of entering STEM, but that the main source of the gap is the lower overall rate of university attendance by men."