If abortion is allowed late enough in the pregnancy for any reason. Most countries abortion that late isn’t legal except for fetal abnormalities or life of the mother.
As mentioned above, China used to pressure and incentivize women to only have one child, most chose to have boys. China allowed late abortions, not sure how late. I’m not sure what other countries.
Some diseases occur more often in a specific gender, so in some cases the sex of embryos are determined in vitro during the IVF process, and let’s say a boy is more likely to have a genetic disease, all the male embryos are discarded. It can be done just because someone desires a certain gender too.