Dear All, I run the following code
Code:
clear 
set obs `=40 * 500 * 10' 
set seed 2803 
egen year = seq(), block(10000) 
egen industry = seq(), block(4000) 
gen x = runiform()

gen x2 = .
forvalues y = 1(1)20 {
  forvalues i = 1(1)50 {
    xtile temp = x if (year==`y')&(industry==`i'), nq(5)
    replace x2 = temp if (year==`y')&(industry==`i')
    drop temp
    local i = `i'+1
  }
  local y = `y'+1  
}
but encounter the error message as
Code:
nquantiles() must be less than or equal to number of observations plus one
Can anyone help me out? Thanks.