yes, but...
The OHV engines are the same for the most part, but a couple of things to remember whan using engines later than 97 is the crank has 8 bolts instead of 6, so you need to have the flexplate or flywheel that matches the engine.
The fuel system was changed in 98 so you need to back date the new engine to work with whats in your chassis.
The electronics arent the same either so back date again to your year.
If I was replacinjg a early model with a later model Id just pull the manifold and switch it over to the old one(most of the sensors are on the manifold also) , use the old wiring harnesses, and make sure the flywheel flex plate go with the engine. The exhaust manifolds will bolt up as far as I know, even though the later heads have different ports.
If your thinking of the SOHC, its a better idea to sell your truck and buiy one with the SOHC already installed IMO.