Dear all,

I am facing difficulties in dropping some variables conditional on the missing observations of one variable.
I have a dataset of prices, volumes and a measure of liquidity for 200 stocks. The dataset is a time series made of 601 variables, date, p1-p200, vo1-vo200 and liq1-liq200.
I want to drop p*, vo* and liq* if liq* has less than 30 observations.
I have tried
Code:
foreach var of varlist * {   
    qui count if missing(`var')     
    if r(N) >= 7535 drop `var'   
}
But there is a big problem with this approach. If let's say p1 has less than 30 but not vo1 than it drops p1 and keeps vo1.

Any suggestion?

Best

Stefano