randomization of participants in districts in my dataset

Job ID: 31301199

Budget: $25 – $50 USD

I need to randomize a sample of my participants across groups between treatment (1) and control (0) while maintaining gender balance as much as possible within groups. The data is classified into groups which are districts. I need to do the randomization ideally in stata software.