I am working on a similar command like this
Stata | FAQ: Listing observations in a group that differ on a variable
However, what if egenotype has a missing value for some and I don’t want Stata to report this case as diff. How can I use such commands?
To make my question clear I am changing the observations in the above STATA example as follows
eid egenotype
0 vv
0 .
1 vv
1 ww
2 ww
2 vv
2 .
I want STATA to list only those samples that differ in non-missing values of the variable egenotype for each individuals.
If I use the command in the above STATA link, that is :
by eid (egenotype), sort: gen diff = egenotype[1] != egenotype[_N]
. list eid egenotype if diff
Then, STATA reports the eid 0, 1, and 2 as having differing genotypes for each individual. However, I don’t want STATA to consider the difference in values of egenotype observed eid 0 as diff because it is a difference between “VV” and “.”. How do I rearrange the above command to list samples that differ only in non-missing values of egenotype ?
Thank you
Stata | FAQ: Listing observations in a group that differ on a variable
However, what if egenotype has a missing value for some and I don’t want Stata to report this case as diff. How can I use such commands?
To make my question clear I am changing the observations in the above STATA example as follows
eid egenotype
0 vv
0 .
1 vv
1 ww
2 ww
2 vv
2 .
I want STATA to list only those samples that differ in non-missing values of the variable egenotype for each individuals.
If I use the command in the above STATA link, that is :
by eid (egenotype), sort: gen diff = egenotype[1] != egenotype[_N]
. list eid egenotype if diff
Then, STATA reports the eid 0, 1, and 2 as having differing genotypes for each individual. However, I don’t want STATA to consider the difference in values of egenotype observed eid 0 as diff because it is a difference between “VV” and “.”. How do I rearrange the above command to list samples that differ only in non-missing values of egenotype ?
Thank you

Comment