Hi statalist,
Please consider the following sample data:
Here, hhs, are identified by the variable id. HHs can have different items of value, with the most valuable item having itemid=1 and items of lower value would therefore be numbered by 2, 3, etc. As can be seen, some hhs can have only one item of value, some can have more than one. Under these scheme, all hhs should have at least one item with itemid=1 (if it is their only valuable item, it would have itemid=1), and can have other items with higher values of itemid. Thus the number of observations when itemid=1 should equal the number of unique households, given by id.
However, there is some error in my data where I suspect some hhs do not have any item with itemid=1. For eg, in the sample data, id 112, and id 115 have one item each and should have had itemid=1 against each of these items. But instead, 112 has itemid 2 against it, and 115 has itemid 3 against it.
I am trying to write a code that would flag these two ids:112 and 115, which do not have 1 on their itemid but have some other number.
it would be great if anyone could suggest how to go about this problem. Please comment if I have not been able to explain the problem well and you need clarification.
Thanks,
Please consider the following sample data:
Code:
* Example generated by -dataex-. To install: ssc install dataex clear input str3 var1 str6 var2 "id" "itemid" "111" "1" "111" "2" "111" "3" "112" "2" "113" "1" "113" "2" "114" "1" "114" "2" "114" "3" "115" "3" end
However, there is some error in my data where I suspect some hhs do not have any item with itemid=1. For eg, in the sample data, id 112, and id 115 have one item each and should have had itemid=1 against each of these items. But instead, 112 has itemid 2 against it, and 115 has itemid 3 against it.
I am trying to write a code that would flag these two ids:112 and 115, which do not have 1 on their itemid but have some other number.
it would be great if anyone could suggest how to go about this problem. Please comment if I have not been able to explain the problem well and you need clarification.
Thanks,
Comment