Statalist


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

st: AW: preserving missing values when using total


From   "Martin Weiss" <martin.weiss1@gmx.de>
To   <statalist@hsphsun2.harvard.edu>
Subject   st: AW: preserving missing values when using total
Date   Sun, 8 Mar 2009 11:53:16 +0100

<> 



*************
by year, sort : egen float accounts_total = total(accounts), missing
*************



HTH
Martin

-----Ursprüngliche Nachricht-----
Von: owner-statalist@hsphsun2.harvard.edu
[mailto:owner-statalist@hsphsun2.harvard.edu] Im Auftrag von Srini
Gesendet: Sonntag, 8. März 2009 01:30
An: statalist@hsphsun2.harvard.edu
Betreff: st: preserving missing values when using total

Hi,

After data manipulation, I have a data set with multiple observations per
year. I used total to sum over these observations to get collapse the data,
but realized that the process was replacing missing values with zeroes.

            year    accounts       accounts_total
district 1  72         .                 0
district 1  72         .                 0
district 1  72         .                 0
district 1  72         .                 0
district 1  73         .                 0
district 1  73         .                 0
district 1  73         .                 0
district 1  74        10                 34
district 1  74        20                 34
district 1  74         4                 34
district 1  75         15                32
district 1  75         17                32

In my case, accounts data is missing for the first few years. How can I
ensure that when I take the total by year, accounts_total = . for year = 72
and year = 73? Currently, STATA has accounts_total = 0 for those years.

If there isn't a specific command, I can try and use the method suggested by
Nick Cox in 2005 in this thread: Egen functions - preserving missing values?

Thanks.

Sinduja


      

*
*   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–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index