*! 1.0.0 15Apr97 (Jeroen Weesie/ICS) -- utility for hh-package STB-43 dm58 program define hh_slct version 5.0 * interface to hh package hh_is local hnr : char _dta[HH_nr] local idrop : char _dta[HH_idrop] * parse command line local if "opt" local in "opt" local options "ANy ALl Gen(str)" parse "`*'" if "`gen'" == "" { di in re "option -gen- required" exit 198 } confirm new var `gen' tempvar touse * deal with if/in selection if length("`all'`any'") > 3 { di in re "At most one the options {any|all} may be specified" exit 198 } if "`if'`in'" == "" & "`all'`any'" != "" { di in bl "{any|all} should be specified only with -if- or -in- clauses" } if "`if'`in'" != "" { mark `touse' `if' `in' quiet replace `touse' = 0 if `idrop' sort `idrop' `hnr' `touse' if "`any'" != "" { quiet by `idrop' `hnr' : replace `touse' = `touse'[2] if _N>1 } else if "`all'" != "" { quiet by `idrop' `hnr' : replace `touse' = `touse'[1] } else { quiet capt by `idrop' `hnr': assert (`idrop') | (`touse'[1]==`touse'[2]) if _rc { di in re "-if- and -in- should select both partners or none" exit 198 } } rename `touse' `gen' } else { gen byte `gen' = !`idrop' } end