I am trying to run a simple regression for a school assignment. The question asks me to run a regression and restrict my estimation to var == 1.

Initially, I wrote the following code:

Code:
keep if var == 1
reg y x
and then ran my regressions.

But, my classmate answered the question with a differently. Rather than dropping observations where var!=1, he wrote

Code:
reg y x if var == 1
We get different results for our regressions.

Why do we get different results?