 Anderson was elected as a Democratic-Republican to the Eleventh, Twelfth, and Thirteenth Congresses.He was elected to the Fifteenth Congress.He was appointed an associate judge of the county court on January 5, 1826, and resigned in 1828 to become an inspector of customs in Philadelphia.