Reputation: 23
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?
Upvotes: 1
Views: 16588
Reputation: 37358
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.
Upvotes: 3