Many thanks for the very useful responses in such a short time. I'm not a former SAS user - more a naive R user who didn't realise that a sort wasn't necessary!
Jim, your solution worked really well - thanks. Thanks again for the great solutions. Steve ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.