*! version 1.0.0 August 1, 2006 @ 10:48:25 *! List information on (person specific) sequences program sqstattab1 version 9 syntax [varlist(default=none)] [if] [in] [, * ] // Sq-Data if "`_dta[SQis]'" == "" { di as error "data not declared as SQ-data; use -sqset-" exit 9 } preserve // if/in if "`if'" != "" { tokenize "`if'", parse(" =+-*/^~!|&<>(),.") while "`1'" != "" { capture confirm variable `1' if !_rc { local iflist "`iflist' `1'" } macro shift } } if "`iflist'" != "" CheckConstant `iflist', stop marksample touse, novarlist // Check if hand made varlist are constants above time if "`varlist'" != "" CheckConstant `varlist' local varlist `r(checked)' // Use egen-erated sequence-information if "`varlist'" == "" { local SQlength: char _dta[SQlength] local SQelemcount: char _dta[SQelemcount] local SQepicount: char _dta[SQepicount] local SQgapcount: char _dta[SQgapcount] local SQgaplength: char _dta[SQgaplength] local varlist "`SQlength' `SQelemcount' `SQepicount' `SQgapcount' `SQgaplength'" // Clean Varlist foreach var of local varlist { capture confirm variable `var' if _rc local varlist: subinstr local varlist `"`var'"' `""', all } format `varlist' %4.0f } // Output keep `_dta[SQiis]' `_dta[SQis]' `varlist' `touse' quietly by `_dta[SQiis]': keep if _n==1 & `touse' foreach var of local varlist { di as text _n "-> tabulation of " as result "`var'" tab `var' if `touse', `options' } end program CheckConstant, rclass syntax varlist(default=none) [, stop] sort `_dta[SQiis]' foreach var of local varlist { capture by `_dta[SQiis]': assert `var' == `var'[_n-1] if _n != 1 if _rc & "`stop'" == "" { di as res "`var'" as text " is not constant over time; not used" local varlist: subinstr local varlist "`var'" "", word } if _rc & "`stop'" != "" { di as error "`var' is not constant over time" exit 9 } if "`stop'" == "" { return local checked "`varlist'" } } end