# sum
#
# Output: scalar or series
# Argument: x (series, matrix or list)
<hansl>
clear
scalar one = 1
catch scalar su = sum(one)
clear
matrix one = 1
scalar su = sum(one)
nulldata 3
series one = 1
su0 = sum(one)
su = sum(1) ### clear, the argument is treated as list
### with only element -- series number 1
scalar unit = 1
su2 = sum(unit)
#also
eval sum(1.0)
catch eval sum(1.1)
eval sum(0) # zero is interpreted as a list consisting only of the constant
eval sum(const) # interestingly here 'const' is interpreted as series!!!
series su3 = sum($pd)
print su3
<hansl>
My opinion: help lacks explanations of default interptetaions.
SCALARS are not listed among arguments types AT ALL
Hence, INTEGERS (including $pd) should be interpreted as one of the listed
types (i.e. series, matrix or list)
Examples above show that integers are interpreted
as lists with 1 element: global series NUMBER inputted scalar
Since, in sum(1) 1 is the number of series and this series
builds a list with one element
1) In any case it is desirable to describe default integers
behavior
Also why interpretation of 0 and const is different
in ols y 0 xlist and ols y const xlist 0 and const are the same
2) I do not know whether some changes are need but
it is obvious that help to sum() should explain such things
Oleh