One thing to keep in mind when calculating P/E on an index is that the E (earnings) can be very close to zero. For example, if you had a stock trading at $100 and the earnings per share was $.01, this would result in a P/E of 10,000, which would dominate the P/E you calculate for the index. Of course negative earnings also skew results.
One way to get around this would be to calculate the average price of the index and the earnings per share of the index separately, and then divide the average price of the index by the average earnings per share of the index.
Different sources calculate these numbers in different ways. Some throw out negative P/Es (or earnings per share) and some don't. Some calculate the price and earnings per share separate and some don't, etc...
You'll need to understand how they are calculating the number in order to compare it to PEs of individual companies.