Question

I am trying to get the difference between the natural logarithms of two consecutive observations for a set of variables.

My approach is as follows

. gen abandon_qry_ln = ln(abandon_qry) - ln(abandon_qry) [_n-1]

But I get the error weights not allowed.

Any idea what could be the issue?

Was it helpful?

Solution

You could work with

gen difference = ln(abandon_qry) - ln(abandon_qry[_n-1]) 

or

gen ln_abandon_qry = ln(abandon_qry) 
gen difference = ln_abandon_qry - ln_abandon_qry[_n-1] 

You were trying to subscript an expression. You may subscript a variable or a matrix in Stata, but not in general an expression.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top