At what age do children start to have the ability to categorize others based on social identities like race and gender?

Children as young as three years old have been found to have the ability to categorize others based on social identities like race and gender.