When two or more persons are included in the same indictment or information, a court may on the application of the prosecuting attorney, at any time before the defendants have gone into their defense, direct any defendant to be discharged from the indictment or information, in order that he may be a witness for the prosecution.
SDCL 23A-22-7