 After he studied at the university for more than a year, he was due to be recommended for an official post, but he declined the recommendation on the basis that he felt that his studies were not done, and he ended up studying for more than 10 years at the university, particularly gaining expertise in the "Zuo Zhuan" and the "Book of Han".At some point, Pei Yan passed the imperial examination, and he was made the food storage officer at Pu Prefecture (濮州, roughly modern Heze, Shandong).He eventually served successively as assistant imperial censor, imperial archivist, deputy minister of defense, and eventually "Huangmen Shilang" (黃門侍郎)