Nick Winter
> Actually, my last won't do it. This will:
>
> foreach v1 of varlist v4-v50 {
> foreach v2 of varlist v1 v2 v3 {
> local type : type `v1'
> if substr("`type'",1,3)=="str" {
> di
> di "{txt}Tabulation of `v2' for missing `v1'
> (string):"
> tab `v2' if `v1'=="&"
> di
> }
> else {
> di
> di "{txt}Tabulation of `v2' for missing `v1'
> (numeric):"
> tab `v2' if `v1'==.
> }
> }
> }
>
>
> The "local type:" line checks the variable type, then proceeds
> accordingly.
Another way to do it, implementing my last posting:
1. Fix those "&". Better done sooner rather than later.
foreach v of var * {
capture replace `v' = "" if `v' == "&"
}
2. Use the -missing()- function.
foreach v1 of varlist v4-v50 {
foreach v2 of varlist v1 v2 v3 {
di
di "{txt}Tabulation of `v2' for missing `v1'"
tab `v2' if missing(`v1')
}
}
Nick
[email protected]
*
* For searches and help try:
* http://www.stata.com/support/faqs/res/findit.html
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/