P/E index construction

For my thesis, I need the P/E ratio for several indices. I have downloaded historical price and earnings data for the companies in these indices. However, now I am wondering how I can obtain the P/E ratio of the overall index. There is one problem I encounter:

for example, in 1970-1975, there are only 20 companies in this index with available data
For 1975-1980, there are 25 companies in this index with available data. This implies that the P/E ratio does not only change by the fact that circumstances change, but also because new companies add to the index with new data.

Therefore, I think I can not simply take the average of available companies in this index. Anyone who knows how I can construct such an index? Hope somebody can help me out.