Sahih Muslim Book 4, Hadith Number 2091.

Chapter : Standing up on seeing a bier.

It is narrated on the authority of ‘Amir Ibn Rabi’a (may Allah be pleased with him) that the Holy Prophet (may peace be upon him) said: Should any one of you come across a funeral procession, and if he does not intend to accompany it, he must stand up until it passes by him or is placed upon the ground before it passes him.