Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: st: sum issue (wrong values)


From   Maarten Buis <[email protected]>
To   [email protected]
Subject   Re: st: sum issue (wrong values)
Date   Wed, 24 Oct 2012 12:32:33 +0200

On Wed, Oct 24, 2012 at 12:13 PM, Christian Bärtsch wrote:
> I have a issue using the sum function of STATA. I have a data set,
> where I have a variable called latency_int (type: int; and something
> over 5700 values). I use the command sum(latency_int). There I get the
> minimum of 2 and the maximum of 1999 even though the data set contains
> values from 44 to 81000 (those values are shown when I use
> list(latency_int).

I suspect that you have value labels for the variable latency_int, and
that that is the stuff you see when you type -list latency_int-.
However, sum() uses the actual values and not the labels. To see how
this might work, see:

*----------- begin example -----------
// sum seems to work
clear all
set obs 10
gen x = _n
list
gen sumx = sum(x)
list

// now it looks wrong
label define x 1 "100"
label value x x
drop sumx
gen sumx = sum(x)
list

// but now it looks correct again
list, nolabel
*------------ end example ------------
(For more on examples I sent to the Statalist see:
 http://www.maartenbuis.nl/example_faq )

-- Maarten

---------------------------------
Maarten L. Buis
WZB
Reichpietschufer 50
10785 Berlin
Germany

http://www.maartenbuis.nl
---------------------------------

*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/faqs/resources/statalist-faq/
*   http://www.ats.ucla.edu/stat/stata/


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index