During the War of 1812, Anderson raised a group of volunteers known as the Mifflin Guards. He was commissioned captain on September 10, 1814 and served for three months at Fort DuPont. He served in the Pennsylvania Militia and was promoted to the rank of lieutenant colonel in the One Hundredth Regiment, Second Brigade, Third Division, on August 3, 1821.
