The Microfoundations of macrosociology