New functions to return the sum and weights associated with categorical variables