Dear All, Consider the following dataset,
I wish to count the new addition of patent ("ipc") for each company ("symbol") and each year, after the starting year of the observations (each company has different starting years). For example, the starting year of "symbol"="000001" is 2010. There are two types of patents, i.e., G06 and G07. After 2010, you can see the year is 2013, with patents G06, G07, and H04. Thus, a "wanted" variable takes 1 in year 2013 for "symbol"="000001". For the same company, in year 2016, G06 has appeared in the previous years (2010, 2013). Thus, there is no new addition and "wanted" variable = 0. Similarly, wanted = 0 in year 2017 since G06 and H04 has appeared in previous years (2010, 2013, and 2016). Any suggestions? Thanks.
Code:
clear input str12 symbol float year str3 ipc "000001" 2010 "G06" "000001" 2010 "G06" "000001" 2010 "G07" "000001" 2013 "H04" "000001" 2013 "G06" "000001" 2013 "G07" "000001" 2013 "H04" "000001" 2013 "G06" "000001" 2013 "G06" "000001" 2013 "G06" "000001" 2016 "G06" "000001" 2016 "G06" "000001" 2017 "G06" "000001" 2017 "G06" "000001" 2017 "G06" "000001" 2017 "G06" "000001" 2017 "H04" "000001" 2017 "G06" "000001" 2017 "G06" "000001" 2017 "G06" "000001" 2017 "G06" "000001" 2017 "G06" "000002" 2002 "E04" "000002" 2002 "E04" "000002" 2004 "E06" "000002" 2004 "A47" "000002" 2004 "E04" "000002" 2004 "E06" "000002" 2004 "E06" "000002" 2004 "A47" end
Comment