Hi, I am a beginner in Stata.
Recently, I am suffering from some errors that happen only on do-file.
For instance,
Code:
sysuse auto, clear
generate lprice = log(price)
preserve
collapse (max) max_lprice = lprice max_mpg = mpg (iqr) iqr_lprice = lprice iqr_mpg = mpg if !missing(rep78), by(rep78)
sort rep78
restore
This code works very well if I use command window line-by-line, but does not work on do-file.
(The code above is cited from "An introduction to Stata programming, CF Baum")

I have found a lot of same kind of problems.
So, My question is in a sentence that "Is there any difference between do and command window?"

Thank you for your time to read this question.