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

st: Collapse & Missing Values


From   "Eric G. Wruck" <[email protected]>
To   [email protected]
Subject   st: Collapse & Missing Values
Date   Wed, 28 Sep 2005 13:57:10 -0400

I just learned, rather inconveniently, that collapse doesn't work the way I'd like when encountering missing values. Here's an example:
. l

+----------------------+
| date amount |
|----------------------|
1. | 10-Oct-1990 200 |
2. | 10-Oct-1990 -75 |
3. | 10-Oct-1990 64 |
4. | 11-Oct-1990 . |
5. | 12-Oct-1990 107 |
|----------------------|
6. | 12-Oct-1990 . |
+----------------------+

. collapse (sum) net_amt=amount, by(date)

. l

+-----------------------+
| date net_amt |
|-----------------------|
1. | 10-Oct-1990 189 |
2. | 11-Oct-1990 0 |
3. | 12-Oct-1990 107 |
+-----------------------+

.
The problem is for the single 11-Oct-1990 observation. After collapsing, the missing value becomes a zero; in this instance I would have preferred it remain missing. The 12-Oct-1990 treatment is fine & what I expected. I suppose I could delete observations before performing the collapse but it would be better if there was some other option. Is there?


Grazie,


Eric

--

===================================================

Eric G. Wruck
Econalytics
2535 Sherwood Road
Columbus, OH 43209

ph: 614.231.5034
cell: 614.330.8846
eFax: 614.573.6639
eMail: [email protected]
website: http://www.econalytics.com

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