The Messenger of Allah ﷺ saw a man standing apart who had not prayed with the congregation. He asked, "So-and-so, what kept you from praying with the people?"The man replied, "Messenger of Allah, I am in a state of major ritual impurity and there is no water."He said, "Use clean earth, for that will suffice you."
أن رسول الله ﷺ رأى رجلا معتزلا لم يصل في القوم، فقال: يا فلان! ما منعك أن تصلي مع القوم؟ فقال: يا رسول الله! أصابتني جنابة ولا ماء، فقال: عليك بالصعيد؛ فإنه يكفيك.
Bukhari narrated it in the Book of Tayammum (344), and Muslim in the Book of Mosques (682), both of them through Abu Raja Attaradi, from Imran bin Husayn, who mentioned something similar. It is part of a longer hadith, which you can find in Dalail Nubuwwah.