Valence transition at the surface of Sm in Sm metal and of Yb in YbAu2