Best subset selection uses the branch and bound algorithm to speed up
Answering my own question in the last post : best-subset selection is not stepwise. The speed was achieved due to the specific algorithm applied. Same results from R stepwise and SAS best subset were obtained due to coincidence. After I remove some variables the outputs are no longer the same. The output from R best subset is still not exactly the same as SAS best subset. The differences are very small, only on several predictors with trivial effects. I discussed this question on SAS community , got very good comments that remind me obviously R did not search for all the combinations either. Some speed-up algorithm must have been applied. Then I sent an email to SAS technical help ( follow this page ), and got a reply in a day. The algorithm is called " Furnival-Wilson leaps-and-bounds " (1974), which seems quite basic in computer science after I figured out what it is. This article is fairly easy to read: Branch and bound in statistical data analysis D.J.Hand. It sca...