To demonstrate that low P/E stocks outperform high P/E stocks, it's necessary to use a collection of stocks belonging to a particular index or exchange. It does no good to anyone to demonstrate low P/E outperformance on a collection of random stocks that was spit out by the complete Compustat database. Unfortunately, it is not easy to find the historical compositions or constituents of various indexes. Even the Standard and Poor's website only lists the S&P 500 constituents (as well as changes to this index) back to the year 2000.
The answer to garnering this historical data lies within Compustat. One can return S&P 500 data, and one can also specify the exchange that each stock belongs to, which would allow appropriate groupings of each stock during processing.
To grab only stocks belong to the S&P 500:
After selecting "Entire Database" in the "Search" area, select CPSPIN under the optional heading "conditional statements".
To return the exchange that a particular stock belongs to:
Select the ZLIST variable in the "Variables" section.
You now have a way to group stocks by exchange and identify stocks belonging to the S&P 500.