[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

From |
"Nick Cox" <n.j.cox@durham.ac.uk> |

To |
<statalist@hsphsun2.harvard.edu> |

Subject |
st: Re: -1 observations deleted |

Date |
Wed, 14 Aug 2002 15:00:16 +0100 |

"Lee Chuntao" <chtl@econ.hku.hk> > I need to connect a lot of files together by using the command "append > using". Those files all contain the same six variables, but different > numbers of observations. Some contain 0 observations. I also need to delete > some observations in some conditions. For the zero-observation files, surely > i deleted zero observation by using "drop if condition", but stata replied > "-1 observations deleted". This is something easily be misunderstood. My > question is, why stata not report "0 observation deleted". I agree that's a puzzling message. But I don't understand what the real problem is. If you don't know that a file contains 0 observations you can check ahead of reading it in: qui d using file if r(N) > 0 { append using file } That is, a -describe- without reading in the file will leave behind a count of the number of observations, which you can then use to avoid reading in an empty data set. > another question is also related to zero-observation files. there is a > variable named date, and i need to sort obs. decendingly. If i use > "gsort -date", there is an error, but if i use the following commands, it > works well: > gen n_date = -date > gsort n_date > drop n_date > this seems rather stupid since we have a command "gsort -varname" > can stata co. upgrade the gsort command? Let me get this straight. You are reporting a bug: you cannot use -gsort- to reverse sort a file with 0 observations. OK. You could get round this by writing your own copy of -gsort-, say -gsort2-, which would be the same as -gsort- except that early on you have these lines qui count if r(N) < 2 { exit 0 } which will throw you out gently without changing your data set (the way I see it, any data set with <2 observations is invariant under any kind of -sort-, so the -sort- is redundant). If the problem is that you are doing this in an automated way, and you are not clear in advance which files have zero observations, then my answer is as above. Nick n.j.cox@durham.ac.uk * * 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/

- Prev by Date:
**st: adapt in GLLAMM** - Next by Date:
**st: RE: single spaces in outfile** - Previous by thread:
**st: adapt in GLLAMM** - Next by thread:
**st: RE: single spaces in outfile** - Index(es):

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