I tried this:

collapse (mean) mpg_all ///
, by(state_code.year.month)

Received this error:

factor-variable and time-series operators not allowed
(error in option by())

What does this mean, Please Help!