Hello everyone,
I would highly appreciate your help with respect to a command that generates a variable which is the sum of the distinct values of a variable per group. To explain with example, consider the auto dataset:
I need to create a variable, say "x", which is the sum of the distinct values of variable "rep78" per each category of the variable "foreign". So, at the end, my x variable will be with 2 levels; the first is the sum of the distinct values of rep78 when foreign =1, and the second is the sum when foreign=0
Thank you
I would highly appreciate your help with respect to a command that generates a variable which is the sum of the distinct values of a variable per group. To explain with example, consider the auto dataset:
Code:
sysuse auto, clear
Thank you
Comment