I believe that we should always build for where things will be after many years. With that in mind, when installing sliding doors, I’ve learned not to shim and nail the top of the frame to the header, especially if it is a three-panel door. Over time, the header may sag a little, placing a load on the door frame and binding the door and/or the glass.
To maintain stability and alignment of the horizontal frame, I install countersunk, flat-head, smooth-shank screws up through the top of the door frame. When the header sags, the screws gently protrude, allowing them to be tightened further in years to come. Likewise, the trim should not be nailed to the header but only to the horizontal frame. The trim will slide up the surface of the wall if necessary.
John Panak, Austin, TX