*! version 1.0.0  11Nov1999 _grpos.ado F.Wolfe identifies observations
*! with at least n (default = 1) positive values (default = !. & !0)
*! egen newvar = rpos(varlist), Minpos(integer 1) Lowlim(integer 0
*! minpos = min no of pos values Lowlim = the highest non pos value
program define _grpos
	version 6

	gettoken type 0 : 0
	gettoken g    0 : 0
	gettoken eqs  0 : 0

	syntax varlist(min=1) [if] [in] [, Minpos(integer 1) Lowlim(integer 0)]
	quietly {
		tokenize `varlist'
		gen `type' `g' = cond(`1'==. | `1' <= `lowlim',0,1) `if' `in'
		mac shift
		while "`1'"!="" {
			replace `g' = `g' + cond(`1'==. | `1' <= `lowlim',0,1) `if' `in'
			mac shift
		}
		replace `g' = cond(`g' >= `minpos',1,0) `if' `in'
	}
end