Good morning everyone,

I have been asked to try to visualize a first step regression. Anyway, in order to do this, my datas must be grouped in a certain way with the following command:



sum l_ln_km_IH

gen l_ln_km_IH_0 = ‘r(min)’

forvalues i = 10(10)90 {

egen l_ln_km_IH_‘i’ = pctile(l_ln_km_IH), p(‘i’)

}

gen cat_l_ln_km_IH_temp = 0

local k = 1

forvalues i = 10(10)90 {

replace cat_l_ln_km_IH_temp = ‘k’ if l_ln_km_IH > l_ln_km_IH_‘i’

local k = 1 + ‘k’

}

bysort cat_l_ln_km_IH_temp : egen cat_l_ln_km_IH = mean(l_ln_km_IH)

drop cat_l_ln_km_IH_temp



Anyway, this command does not work. I have problems on the options (i) on pctile and on r(min). I have already tried to not add the ' ', but it does not change anything.

Morever, I don't understand how this command groupes the datas, in other words, I do not understand the logic behind this command.



Can someone help me?

Thank you