Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

Re: st: Re: generating a new variable with the egen command


From   agostino@unical.it
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: Re: generating a new variable with the egen command
Date   Mon, 28 Nov 2005 16:35:47 +0100

thank you Rodrigo for your prompt answer!
I've tried your way, and it is better: now the sum is precise in most of the 
cases, but still for some observations I obtain the rounded numbers, how weird!

thank you again
Mariarosaria

Citazione Rodrigo Alfaro <ralfaro@bu.edu>:

> This sounds weird, try the following steps:
> 
> sort id year
> by id year: egen double newvar=sum(oldvar)
> 
> then list, sum or tab to see the values of newvar.
> 
> Rodrigo.
> 
> ----- Original Message ----- 
> From: <agostino@unical.it>
> To: <statalist@hsphsun2.harvard.edu>
> Sent: Monday, November 28, 2005 9:53 AM
> Subject: st: generating a new variable with the egen command
> 
> 
> > Dear all,
> > I'm trying to generate a new variable given by the sum of an existing 
> > variable
> > by year (as I have 2 six month observations for the same year) and 
> > individual.
> > The command is the following:
> > egen newvar=sum (oldvar), by(id year)
> >
> > the problem is that the original values are, for instance: 42224464 and
> > 67090781, but the sum that STATA computes is 109000000, instead of 
> > 109315245.
> > Why does it round like that?
> > The old variable is stored as "double", I have tried to change the
> storage
> > type, using recast, but STATA does not allow to do it, as many values 
> > would be
> > changed...
> > Thank you very much for any suggestions
> > Kind regards
> >
> > Mariarosaria Agostino
> >
> > Dipartimento di Economia e Statistica
> > UniversitÓ della Calabria
> > ponte P. Bucci, 87036 Arcavacata di Rende (CS)
> > Italia
> >
> >
> >
> >
> > -------------------------------------------------
> > This mail sent through IMP: http://horde.org/imp/
> >
> > *
> > *   For searches and help try:
> > *   http://www.stata.com/support/faqs/res/findit.html
> > *   http://www.stata.com/support/statalist/faq
> > *   http://www.ats.ucla.edu/stat/stata/
> > 
> 
> *
> *   For searches and help try:
> *   http://www.stata.com/support/faqs/res/findit.html
> *   http://www.stata.com/support/statalist/faq
> *   http://www.ats.ucla.edu/stat/stata/
> 




-------------------------------------------------
This mail sent through IMP: http://horde.org/imp/

*
*   For searches and help try:
*   http://www.stata.com/support/faqs/res/findit.html
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/



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