![]() |
From | Ronnie Babigumira <rb.glists@gmail.com> |
To | statalist@hsphsun2.harvard.edu |
Subject | Re: st: RE: RE: tokenize and missing |
Date | Tue, 29 Jan 2008 17:43:11 +0100 |
Bug fix:
*! NJC 1.0.1 28 January 2008 program listmissing
version 8 syntax [varlist] [if] [in] [, *] marksample touse, novarlist qui count if `touse' if r(N) == 0 error 2000
qui foreach v of local varlist { count if `touse' & missing(`v') if r(N) local vlist `vlist' `v' }
local Vlist : subinstr local vlist " " ",", all list `vlist' if missing(`Vlist'), `options' end
-----Original Message-----
From: owner-statalist@hsphsun2.harvard.edu
[mailto:owner-statalist@hsphsun2.harvard.edu] On Behalf Of Nick Cox
Sent: 28 January 2008 16:49
To: statalist@hsphsun2.harvard.edu
Subject: st: RE: tokenize and missing
I am pleased to see -nmissing- being useful to anyone. But the problem
here, as I understand it, can be tackled more directly:
*! NJC 1.0.0 28 January 2008 program listmissing
version 8 syntax [varlist] [if] [in] [, *] marksample touse, novarlist qui count if `touse' if r(N) == 0 error 2000
qui foreach v of local varlist { count if `touse' & missing(`v') if r(N) local vlist `vlist' `v' }
local vlist : subinstr local vlist " " ",", all list `vlist' if missing(`vlist'), `options' end
Nick
n.j.cox@durham.ac.uk
Ronnie Babigumira
I have a quarterly data set and I am trying to identify missing cases
houscode qtr wage_ld biz_lead
72 1 0 0
81 1 0 1
81 2 . 1
11 3 0 1
10 4 . .
9 1 1 0
I started by using Nick Cox's very useful -nmissing- (ssc install
nmissing)
Which gave me
wage_ld 2
biz_lead 1
Knowing which variables have missing cases, I
list if mi(wage_ld, biz_lead)
However, to generalize it (I will be doing it by quarter) I used
nmissing
tokenize `r(varlist)'
list if mi(`1' `2')
This works for the data as it is, however, you will notice that the
missing cases are in qtr2. So, if I did this analysis by quarter and I
keep if qtr == 1
nmissing
tokenize `r(varlist)'
list if mi(`1', `2')
I get ........invalid syntax...............
I reckon this is coming from the fact that indeed for qtr == 1, I do not
have two variables with missing data. So, is there a way I can tweak this to allow it to proceed?
*
* 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/
*
* 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/
* * 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/
© Copyright 1996–2025 StataCorp LLC | Terms of use | Privacy | Contact us | What's new | Site index |