I'm trying to clean up a large dataset with many stocks. The current dataset i have contains every stock that has ever existed and im trying to cut it down to all the stocks that have ever been in the S&P 500. I have a date column, a ticker column, a closing price column. Not all the stocks in the S&P 500 were added to the index at the same time and some of the stocks were delisted over time. I have currently have all of the historical data on each stock in the S&P 500. For example, Apple was added into the S&P 500 on Nov 30, 1982, but i have data for Apple going back to 1980. Im trying to write a code that doesn't delete the other stock information besides the information from 1980 to Nov 29, 1982 just for Apple. So for example, there will still be information for Amazon from 1970 to the current time, but for Apple the data will start at Nov 30, 1982. So far i was thinking some thing along the lines of this code but it isnt working. DATA CRSP1; SET CRSP; if Ticker='A' then "10Apr1995"d =< date => "05Jun2000"d; else if Ticker='AAPL' then date=>"23Mar2005"d; else if Ticker='AMZN' then date=>"08Dec2012"d; run;
... View more