Many problems in Stata call for selection of observations according to true or false conditions, indicator variables flagging the same, groupwise calculations, or a prearranged sort order. The example of finding the first (earliest) and last nonmissing value in panel or longitudinal data is used to explain and explore these devices and how they may be used together. Negating an indicator variable has the special virtue that selected observations may be sorted easily to the top of the dataset.
BooleG.1847. The Mathematical Analysis of Logic, Being an Essay Towards a Calculus of Deductive Reasoning.Cambridge: Macmillan, Barclay, and Macmillan.
2.
BooleG.1854. An Investigation of the Laws of Thought, on Which are Founded the Mathematical Theories of Logic and Probabilities.London: Walton and Maberley.
3.
BooleG.1952. Studies in Logic and Probability.London: Watts.
4.
CoxN. J.2002. Speaking Stata: How to move step by: step. Stata Journal2: 86–102.
5.
CoxN. J.2015. Speaking Stata: A set of utilities for managing missing values. Stata Journal15: 1174–1185.
6.
GouldW.2003. Stata tip 3: How to be assertive. Stata Journal3: 448.
7.
GreggJ. R.1998. Ones and Zeros: Understanding Boolean Algebra, Digital Circuits, and the Logic of Sets.Piscataway, NJ: IEEE Press.
8.
HailperinT.1986. Boole's Logic and Probability. A Critical Exposition from the Standpoint of Contemporary Algebra, Logic and Probability Theory.Amsterdam: North-Holland.
9.
HarrisonD. A.2006. Stata tip 34: Tabulation by listing. Stata Journal6: 425–427.
10.
IversonK. E.1962. A Programming Language.New York: Wiley.
11.
KnuthD. E.2011. The Art of Computer Programming, Volume 4A: Combinatorial Algorithms, Part 1.Upper Saddle River, NJ: Addison–Wesley.
12.
MacHaleD.1985. George Boole: His Life and Work.Dublin: Boole Press.
13.
MacHaleD.2014. The Life and Work of George Boole: A Prelude to the Digital Age.Cork, Ireland: Cork University Press.