Dear Stata users,
Is there a function similar to "bysort" in Mata?
For example :
The code in Stata is :
Can the above code (i.e. generate variable 'z') be implemented without using a loop in Mata? Or is there efficient loop code? Because there may be many categories in the categorical variable "x".
. Any suggestions are highly appreciated.
Thanks.
Is there a function similar to "bysort" in Mata?
For example :
Code:
clear input double(x y) 1 28 1 13 1 4 2 25 2 23 2 22 2 30 3 15 3 3 3 11 3 24 end putmata x=x y=y
Code:
bysort x : egen z=sd(y)
. Any suggestions are highly appreciated.
Thanks.

Comment