*! 1.0.4 18Jun1997 Jeroen Weesie/ICS STB-39 dm49 program define varrank version 5.0 local varlist "req ex" local if "opt" local in "opt" local options "Rank(str) Cons Display Tol(str)" local weight "aweight fweight iweight" parse "`*'" * scratch tempname r A tempvar touse * selection of rows of implied matrix mark `touse' `if' `in' [`weight'`exp'] markout `touse' `varlist' * handling the constant if "`cons'" != "cons" { local nocons "nocons" } else { local cns "+cons" } * form X*Diag(W)*X, and obtain its rank quiet mat acc `A' = `varlist' if `touse' [`weight'`exp'], `nocons' matrank `A', rank(`r') * display results if "`rank'" == "" | "`display'" != "" { quiet count if `touse' > 0 di in gr "rank of data [" in ye _result(1) in gr " obs, " /* */ in ye colsof(`A') in gr " variables`cns'] = " in ye `r' } if "`rank'" != "" { scalar `rank' = `r' } end