Secret clearance

Currently active duty but I will be leaving the military due to a MED. after my active duty service I’m planning on going to school for about 2-3 years. I was wondering if I’ll lose my secret clearance due to me doing school right after the military? After school I really wanna get into either federal or contractor work for the dod. Will I lose it or is there a way for me to get it back ?