It is narrated from Sayyiduna Anas bin Malik (may Allah be pleased with him) that he said: "The Messenger of Allah (peace and blessings be upon him) came out to us while we were all young men, and he (peace and blessings be upon him) said: 'You must marry; and whoever is not able (to do so), let him fast, for it is a means of curbing desire for him.'"
Imam al-Tabarani (may Allah have mercy on him) said: "No one narrated it from Hisham, from al-Hasan (may Allah have mercy on him), from Sayyiduna Anas (may Allah be pleased with him) except Baqiyyah (may Allah have mercy on him)."
Imam al-Daraqutni (may Allah have mercy on him) said: "Abu Shihab al-Hannat (may Allah have mercy on him) differed from him, for he narrated it from Hisham, from al-Hasan (may Allah have mercy on him), from some of the Companions of the Prophet (peace and blessings be upon him) (may Allah be pleased with them), and that is what is correct."
And it has a supporting narration (shahid) in Sahih al-Bukhari and Muslim from the hadith of Sayyiduna Abdullah bin Mas'ud (may Allah be pleased with him).