Hi,

I have a large data set with 11,854 test variables and 10 covariates (cov).
Using this data set, I am running following program to get p-values for association of test variables with a certain phenotype (pheno).
Code:
unab y:rs10046242-rs13196204

local l: word count `y'

matrix p = J(`l',1,.)
matrix rownames p = `y'
matrix colnames p = "p"

local i = 1
foreach var of local y{
    quietly logit pheno cov1 cov2 cov3 cov4 cov5 cov6 cov7 cov8 cov9 cov10 `var'
    matrix p[`i++',1] = 2*normal(-abs(_b[`var']/_se[`var']))

matlist p
Then, I want to extract a variable with smallest p-values and repeat this program 1,000 times with permuting pheno every time.
The goal of this analysis is to get a distribution of lowest p-value in each step to determine which variables are strongly associated with pheno (I will pick up top 5% of variables).
To achieve this, I am wondering if I can incorporate a command to extract a variable with smallest p-value in each step and a permute command in the program above.

Any suggestions and comments will be really appreciated.