I hope I can explain this.
Say I have a dataset with n observations, and a numerical (discrete/continuous) variable y
I would like, for each observation, to create a new variable as follows:
- first calculate the difference between its own y score and all the other individual y scores in the sample (n-1 calculations, or n calculations if calculating difference with own score, which is 0)
- and then calculate the average of all these differences
How would I do that in Stata?
Thank you in advance
Say I have a dataset with n observations, and a numerical (discrete/continuous) variable y
I would like, for each observation, to create a new variable as follows:
- first calculate the difference between its own y score and all the other individual y scores in the sample (n-1 calculations, or n calculations if calculating difference with own score, which is 0)
- and then calculate the average of all these differences
How would I do that in Stata?
Thank you in advance
Comment