Hi Statalists,
Currently I'm trying to calculate the weights in subsets of my data using
Looking at the output I can see that something is wrong in my understanding of what this code would do as it assigns oiw (open interest weight) of 1 to the first observation in the subset and only proceeds to use the sum of open interest in the following observations (adding to the total sum value as it proceeds down the rows in the subset). I want my code to immediately divide by the open interest for that row in the subset by the total for that subset. Any advice on how to amend the code in order for it to take into account the sum of all observations for open interest in the subset?
PS. I am using Stata 15.1.
Currently I'm trying to calculate the weights in subsets of my data using
Code:
by cusip date exdate cp: gen oiw = open_interest/sum(open_interest)
PS. I am using Stata 15.1.
Comment