will a trans from a 97 ram 1500 4x4 with 5.9 fit in my 98 ram 1500 with a 5.9
Look up "Hollander Interchange Manual" online or go to a local junkyard (aka recycling center) and ask them to look it up just as you have explained it to us here. Right off the top of my head I would tell you to look them over and see if anything visually and length dimensionally looks different. If not then go for it after checking the driveshaft output shaft the tooth count. Easy enough to check, just slip your current driveshaft into the new transmission tail shaft to check before removing your current transmission.
Search Dodge Ram 1500 Questions
Dodge Ram 1500 Experts