The Pan-American Highway is about 47,000 miles long depending on the route you take. There are many options in The United States, Canada, and Mexico because of the large amount of area and number of roads. Central America has only a few roads going north to south.
There are several ways that are used on the Pan-American Highway. It is possible to use buses down all the way to Argentina, except for the Darien Gap. You can drive down, and this can cost money at customs. The cheapest is probably by bus because of customs, and fees for cars on boats going down and going up. You also get to meet locals this way. Cars are also more dangerous than buses because roads in Central America are dangerous and the bus drivers will be used to the area.
Trains are not a viable option because most Central and South American countries do not have international train lines.
Try to avoid areas where cartels operate. Follow the advice for the area you are at.