Statalist


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

st: AW: rowtotal & adding columns


From   "Martin Weiss" <[email protected]>
To   <[email protected]>
Subject   st: AW: rowtotal & adding columns
Date   Wed, 17 Jun 2009 18:01:37 +0200

<> 

Just add more precision...

****
clear*

input double(var1 var2 var3)
1	  5	   9	     
2	  6	  10	   
3	  7	  11	   
4	  8	    12	   
123456789	 123456789  123456789  
321654987  321654987  321654987  
end

egen double tot=rowtotal(var*)
gen double add=var1+var2+var3

format  _all %11.0fc

list, noobs  
****


HTH
Martin


-----Ursprüngliche Nachricht-----
Von: [email protected]
[mailto:[email protected]] Im Auftrag von Nico
Gesendet: Mittwoch, 17. Juni 2009 16:07
An: [email protected]
Betreff: st: rowtotal & adding columns

I am trying to create new columns that are the sum of existing columns, but
the resulting numbers are not what is expected.  As an example, I manually
entered the following var1 var2 var3(no decimals); then used egen
tot=rowtotal(var*); then used gen add=var1+var2+var3.
The resulting tot and add are okay for smaller numbers, but not for the
larger numbers.  The last two rows should be 370,370,367 and 964,964,961
respectively.  Am I doing something incorrectly?  I can't seem to figure it
out...  

Thanks,
Ryan


 
var1	  var2	    var3	      tot 	add
1	  5	    9	      15	         15
2	  6	    10	      18	         18
3	  7	    11	      21	         21
4	  8	    12	      24	         24
123456789	  123456789  123456789  370370368	370370368
321654987  321654987  321654987  964964928	964964992


      

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


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



© Copyright 1996–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index