I am trying to generate a variable y that counts the number of times that my conditions are satisfied within each country-year:
egen y=count(targtype1) if targtype1==14 & nkill>0 & nkill !=. | targtype1==14 & nwound>0 & nwound !=., by(country_txt iyear)
So i want to count observations where either targettype1=14, nkill>0, and nkill !=. or where targtype1=14, nwound>0, and nwound!=. Directly after the if, i use a double equal sign in targtype1==14 because i am testing whether the statement "targtype1 equals 14" is true. But in the proceeding conditions, I use a single equal sign. Is this correct, or should I use a double equal sign in every case? The code runs and seems to be working as is, but I want to be sure that I am not making a mistake.
disclaimer: i am fairly new to stata
Thanks!
egen y=count(targtype1) if targtype1==14 & nkill>0 & nkill !=. | targtype1==14 & nwound>0 & nwound !=., by(country_txt iyear)
So i want to count observations where either targettype1=14, nkill>0, and nkill !=. or where targtype1=14, nwound>0, and nwound!=. Directly after the if, i use a double equal sign in targtype1==14 because i am testing whether the statement "targtype1 equals 14" is true. But in the proceeding conditions, I use a single equal sign. Is this correct, or should I use a double equal sign in every case? The code runs and seems to be working as is, but I want to be sure that I am not making a mistake.
disclaimer: i am fairly new to stata
Thanks!
Comment