Dear Statalisters,

I am applying this QUAIDS code following https://www.statalist.org/forums/for...=1574733094943

However, I have an error message when I am trying to estimate the elasticities.
I got the error said:

Code:
expression too long
r(130);
after the command:

Code:
glo mu`i'`j' "_b[g`i'`j'] - ${mu`i'}*(_b[a`j']${gsum2`j'})- _b[l`i']*_b[b`j']/${bp}*(lnexpmean - (${ap}))^2"
based on this code:

Code:
est store quaidsNNP2 
forv i=1(1)10 {
forv j=1(1)10 {
glo delta=cond(`i'==`j',1,0)
glo mu`i'`j' "_b[g`i'`j'] - ${mu`i'}*(_b[a`j']${gsum2`j'})- _b[l`i']*_b[b`j']/${bp}*(lnexpmean - (${ap}))^2"
cap nlcom (elasexp`i': ${mu`i'}/w`i'mean + 1) (mu`i'`j': ${mu`i'`j'}) (d`i':_b[d`i']), post noheader
if _rc {
est restore quaidsNNP2
nlcom (elasexp`i': ${mu`i'}/w`i'mean + 1) (mu`i'`j'f:(100)*(${mu`i'`j'})) (d`i':_b[d`i']), post noheader
nlcom (elasexp`i': _b[elasexp`i']) (mu`i'`j':_b[mu`i'`j'f]/(100)) (d`i':_b[d`i']), post noheader
}
*Uncompensated price elasticity
if _b[d`i']!=0{
nlcom (elasexp`i': _b[elasexp`i']*_b[d`i']) (elu`i'`j':(_b[mu`i'`j']/w`i'mean - ${delta})*_b[d`i']), post noheader
}
else {
display _b[d`i']
nlcom (elasexp`i': _b[elasexp`i']) (elu`i'`j':(_b[mu`i'`j']/w`i'mean - ${delta})), post noheader
}
*Compensated price elasticity
nlcom (elc`i'`j': _b[elu`i'`j'] + _b[elasexp`i']*w`j'mean), noheader
qui est restore quaidsNNP2
}
}
I have tried to split it such as

Code:
glo muc`i'`j' "(mua`i'`j' : _b[g`i'`j'] - ${mu`i'}*(_b[a`j']${gsum2`j'})) (mub`i'`j' :  _b[l`i']*_b[b`j']/${bp}*(lnexpmean - (${ap}))^2)"
glo mu`i'`j' "$mua`i'`j' - $mub`i'`j'"
However, it doesn't work. The Stata can estimated it but the elasticity values are not include the values of
Code:
(${mu`i'`j'}))
that mentioned in
Code:
glo mu`i'`j' "$mua`i'`j' - $mub`i'`j'"
Any suggestions will be much appreciated.

Thank you in advance.

Chutarat