Language:
كتاب الجنائز
23  
Funerals (Al-Janaa'iz)
(47)
Chapter: when should one sit after standing for the funeral procession?
(47)
باب مَتَى يَقْعُدُ إِذَا قَامَ لِلْجَنَازَةِ
Sahih al-Bukhari 1308

Narrated 'Amir bin Rabi`a:

The Prophet (ﷺ) said, "If any one of you see a funeral procession and he is not going along with it, then he should stand and remain standing till he gets behind it, or it leaves him behind, or the coffin is put down before it goes ahead of him . "

حَدَّثَنَا قُتَيْبَةُ بْنُ سَعِيدٍ، حَدَّثَنَا اللَّيْثُ، عَنْ نَافِعٍ، عَنِ ابْنِ عُمَرَ ـ رضى الله عنهما ـ عَنْ عَامِرِ بْنِ رَبِيعَةَ ـ رضى الله عنه ـ عَنِ النَّبِيِّ صلى الله عليه وسلم قَالَ ‏ "‏ إِذَا رَأَى أَحَدُكُمْ جَنَازَةً فَإِنْ لَمْ يَكُنْ مَاشِيًا مَعَهَا فَلْيَقُمْ حَتَّى يُخَلِّفَهَا، أَوْ تُخَلِّفَهُ أَوْ تُوضَعَ مِنْ قَبْلِ أَنْ تُخَلِّفَهُ ‏"‏‏.‏
Reference : Sahih al-Bukhari 1308
In-book reference : Book 23, Hadith 66
USC-MSA web (English) reference : Vol. 2, Book 23, Hadith 395
  (deprecated numbering scheme)