Cut your yarn, leaving a couple feet or more. Thread the end into a darning needle (with a blunt tip) and pull that through the stitches on your knitting needle. Then pull snug like a drawstring, and sew up the back of the hat. Look here
and scroll down to finishing for how to seam.