Hi dear Professors,
I produce a Table in Excel with the help of the Sumifs formula but now I want to produce it in Stata. I am attaching an image to show the desired output table.
Actually, I want to add all the values of a variable (invention_citation_application) with respect to year and industryid. And in the final column of the table consists of citations per firm (total citation divided by total firms).
Example data and the output image is as follows;
Code:
* Example generated by -dataex-. To install: ssc install dataex
clear
input int(stockcode year invention_citation_application ipatent) byte industryid
  4 2010     1   3 27
  4 2011     2   0 27
  4 2012     0   4 27
  4 2013     0   0 27
  4 2014     0   0 27
  4 2015    11   0 27
  4 2016     1   0 27
 17 2003     .   0 37
 17 2004     .   0 37
 17 2005     .   0 37
 17 2006     .   0 37
 17 2007     .   0 37
 17 2008     .   0 37
 17 2009     .   0 37
 17 2010     .   0 37
 17 2011     .   0 37
 17 2012     .   0 37
 17 2013     .   0 37
 17 2014     .   0 37
 17 2015     .   0 37
 17 2016     .   0 37
 35 2003     .   0 39
 35 2004     7   1 39
 35 2005     .   4 39
 35 2006     .   0 39
 35 2007     .   0 39
 35 2008     .   0 39
 35 2009     .   0 39
 35 2010     .   0 39
 35 2011     .   0 39
 35 2012     .   0 39
 35 2013     .   0 39
 48 2003     .   0 13
 48 2004     .   0 13
 48 2005     .   0 13
 48 2006     .   0 13
 48 2007     .   0 13
 48 2008     .   0 13
 48 2009     .   0 13
 48 2010     .   0 13
 48 2011     .   0 13
 48 2012    28   0 13
 48 2013     .   0 13
 48 2014    13   0 13
 48 2015     .   0 13
 48 2016     .   0 13
333 2013  5241 504 38
333 2014 10217 742 38
end
Array