Statalist The Stata Listserver


[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

Re: st: flagging a specific pattern of values within observations


From   n j cox <[email protected]>
To   [email protected]
Subject   Re: st: flagging a specific pattern of values within observations
Date   Tue, 24 Apr 2007 20:53:25 +0100

To this specific question, here are two more solutions:

list if min(q11a, q11b, q11c) != 1 |
	max(q11a, q11b, q11c) != 3 |
	(q11a + q11b + q11c) != 6

OR

list  if (q11a * q11b * q11c) != 6

(I can't think of a counterexample there that is not contrived.)

On more general checking, with possibly more than 3 items to be ranked

(Jeremy Miles' -reshape- solution, easier than he thought, although
a -reshape long- is what is needed)

reshape long q11, i(fid) string
bysort id (q11): egen wrong = total(q11 != _n)
reshape wide
list if wrong

OR

(Sergiy Radyakin is right to worry about the combinatorics,
but overlooked the fact that concatenation has been in Stata a long time)

rowsort q11?, gen(sorted)
egen all = concat(sorted*)
list if all != "1234567"    (e.g.)

where -rowsort- is to be found on SSC.

Nick
[email protected]

Anirudh V. S. Ruhil

A colleague is trying to accomplish something in a different stats package
and asked if STATA could effect the solution. "Of course", said I. Now I am
scratching my head for the code.  Individuals were asked to rank-order 3
choices. Person 55 did fine, but not Person 21. How can I generate a flag
for such respondent-errors?

----------------------------
fid	q11a	q11b	q11c
55	2		3	1
21	1		2	1
----------------------------

*
*   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–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index