Dear friends, could you help me on writing a stata program to control for sample weight?

Code:
program sumweight, rclass
syntax varlist(numeric) [if] [in] [aw] 
marksample sample 
tempvar y  exp
tempname num den
tokenize `varlist'
quietly {
if "`weight'" != "" {
            tempvar wvar
            local wgt "[`weight'=`wvar']"
        }
mark `wgt'

 su `y' `wgt' if `sample'
 scalar `num' = r(N)
 return scalar obsw = `num'
}
end
sysuse auto
sumweight mpg [aw = weight]
My code returns an error, "=exp required". Thank you!