Hello everyone,
I have a short question about the count function. I want to sort the data based on cusip code and year and then make a variable that gets the value created by the count function if the classification equals to "I". In order to do so I used the following code
As the example shows, for this company in this year, the output variable should get the value of 11. However, if the classification does not have the value "I", it wont get the numeric value that is counted.
I was wondering how the output variable can be assigned to every entry of the firm of this year and not only to the entries that have the classification of "I".
Thanks!
I have a short question about the count function. I want to sort the data based on cusip code and year and then make a variable that gets the value created by the count function if the classification equals to "I". In order to do so I used the following code
Code:
bysort cusip8 fyear: egen Ind=count(classification) if classification=="I"
Code:
cusipnr fyear classification Ind 2 2009 "I" 11 2 2009 "I" 11 2 2009 "E" . 2 2009 "E" . 2 2009 "I" 11 2 2009 "E" . 2 2009 "I" 11 2 2009 "I" 11 2 2009 "I" 11 2 2009 "I" 11 2 2009 "I" 11 2 2009 "I" 11 2 2009 "I" 11 2 2009 "I" 11
I was wondering how the output variable can be assigned to every entry of the firm of this year and not only to the entries that have the classification of "I".
Thanks!
Comment