# How to detect and adjust for stock splits?

I am using a large daily data panel for over 250 companies and over several years. I am concerned about adjusting for stock splits. Is there any program in SAS to detect stock splits? How do I adjust the stock splits?

-
You should get a list of stock splits from your data vendor. Trying to detect splits from pricing history can lead to false positives around earnings season. Also, adjusting for corporate actions gets asked a lot on here [ 1, 2, 3, 4, 5 ]. – chrisaycock Mar 14 at 16:36

yahoo provides adjusted_close. You could use this to detect splits

if this number is less than 0.9 or greater than 1, you have a split

-
What about reverse splits? Or 3-for-2 splits? – chrisaycock Mar 19 at 11:11
you could always change the number that you use as threshold for detecting the split. I have updated my answer to reflect 3:2 and reverse splits – nitin Mar 19 at 19:03
What if the company spins-off a subsidiary? What if they pay a large one-time dividend? My point is that it is extremely dangerous to guess what corporate actions have occurred on the basis of price alone. – chrisaycock Mar 19 at 22:14

Here is R code which calculates the "Split Ratio" for historical data:

library(TTR)
s <- getSymbols("GILD", auto.assign=FALSE)

splitRatio <- s$GILD.Adjusted / s$GILD.Close
names(splitRatio) <- c("SplitRatio")

tail(splitRatio)


However (and this is a big however): the cumulated amount of dividends paid will slowly distort this ratio. For example, IBM hasn't had a stock split since 1999, yet the "SplitRatio" at 2007-01-03 is 0.897. This means that IBM has paid out a total of (1/0.897)-1 = 11% dividends since 2007-01-03.

In addition, I'm not 100% sure that this is the complete story, so I've made this a community Wiki so any correct inassumptions can be addressed.

Update

This answer is wrong, as according to the comment below from Joshua Ullrich:

Don't do this. It's much better to use quantmod::adjustOHLC with Yahoo data. When use.Adjusted=FALSE (the default), the function pulls the split and dividend data from Yahoo and calculates the ratios manually.

-
Don't do this. It's much better to use quantmod::adjustOHLC with Yahoo data. When use.Adjusted=FALSE (the default), the function pulls the split and dividend data from Yahoo and calculates the ratios manually. – Joshua Ulrich Apr 10 at 17:16
@Joshua Ullrich. Thanks for letting me know. I've updated the answer. – Gravitas Apr 11 at 14:24
You could just delete your answer if it's wrong. – chrisaycock Apr 11 at 15:08