I have a variable inc_chng which calculates the changes in the income variable from year to year in my panel dataset. What is the correct code for counting the number of individuals in the panel dataset who had a change in income? At the moment, I can only count the number of observations. Thanks!
Code:
bysort newID (year): gen inc_chng = incometh-incometh[_n-1] lab var inc_chng "income amount change" tab inc_chng replace inc_chng=0 if inc_chng==. sum(inc_chng) if inc_chng>0 sum(inc_chng) if inc_chng<0
0 Response to Code for counting ID within a variable
Post a Comment