Imran Khan averaged, in his last 51 tests (10 years) 51 with the bat and 19 with the ball:
And he bowled almost 10k - almost half his career balls - in that time, so I don't see where people are saying he wasn't really a bowler at the end of his career, or didn't bowl much. In fact, his bowling figures in that time are better than his bowling figures prior. He improved in both disciplines as his career progressed and didn't falter in one for the other, as some keep repeating.
Having read and researched quite a bit, I have to say that the distance is much much closer.
People say that Imran's innings weren't as effective with the bat - despite his high average in his last 10 years - and the same can be said about Sober's bowling. I could be wrong, but I don't recall Sobers winning WI matches with his bowling.
It is said that Sober's feats in batting make up for his bowling, but it simply isn't true. A career average with 37 with the bat, in that discipline, is much better than a career average of 34 with the ball, in consideration to it's own discipline.
When you factor in that Khan averaged 51 for 10 years, most of his career, then that absolutely trumps it. And it doesn't matter if Sobers peaked/averaged 27 at one point, because that 27 equates more with Khan's career average of 37. And if we take Khan's peak average, 51, then it's more in favour of Khan than you may think.