|
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]
Re: st: tokenize and missing
Thanks Maarten
There is an error in
local varlist : subinstr varlist " " ", ", all. I am still trying to figure it out
However, if this did what I think it will do, I would say we are close but not quite there yet. Why? Since the main
reason for doing this is to display suspect cases, your solution would be perfect if the number of variables in
r(varlist) was 5 or less (these would fit nicely on one line).
Unfortunately, the list of suspect cases can be as long as 20. What I know is that when I list them in chunks of 5, they
are OK.
So, do you have a life saving trick for me?
One last thing (a typical case of "Now you tell us"), what I would eventually like to have something like
list id [upto 5 members of r(varlist)] if mi([upto 5 members of r(varlist)])
something like
list id `1' `2' `3' if mi(`1', `2', `3')
But have this work regardless of how many members are in r(varlist) as in if there are 3 it works, if there is 1, it
ignores 2 and 3 (by the way, the list part already ignores 2 and 3 if they dont exist but the function mi fails if they
do not
Do you think I am asking too much of Stata?
Ronnie
Maarten buis wrote:
what about this:
local varlist "`r(varlist)'"
local varlist : subinstr varlist " " ", ", all
list if mi(`varlist')
Hope this helps,
Maarten
--- Ronnie Babigumira <[email protected]> wrote:
Hello,
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?
Ronnie
*
* 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/
-----------------------------------------
Maarten L. Buis
Department of Social Research Methodology
Vrije Universiteit Amsterdam
Boelelaan 1081
1081 HV Amsterdam
The Netherlands
visiting address:
Buitenveldertselaan 3 (Metropolitan), room Z434
+31 20 5986715
http://home.fsw.vu.nl/m.buis/
-----------------------------------------
__________________________________________________________
Sent from Yahoo! Mail - a smarter inbox http://uk.mail.yahoo.com
*
* 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/