I am trying to write out a simple sum program in STATA. I need this program t use in one of my othe programs and none of STATA's pre-definied commans can be used. It is for total sum of a variable. But there is something wrong with the code as STATA says 'xb not found'.

Code:
program define deps
    args xb
    scalar a=0
    local n=1
    while `n'<=_N {
            scalar a=a+xb[`n']
            local n=`n'+1
        }
    display a
end