NYC is better, but still fairly grungy. Boston is substantially better along these metrics. Montreal and Quebec city, two of the oldest and, by dint of age, pedestrian-friendly cities on the continent, are leagues ahead of SF as well in this respect.
SF is great. Love the vibe. But lets not kid ourselves into thinking it is clean.