It was a great question.
We just released a course on that called sex and gender in secondary data analysis. There are algorithms, not only by postal code but also for ethnicity based on name and where you're living, so that intersectional approach is something that the Canadian Institutes of Health Research is now promoting as a gold standard for researchers within government as well as health researchers in the social sciences and elsewhere.