[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]
Re: st: Re: Programming advice
< first line(s) not transmitted>
> are binary responses to a question. The records are paired with the
> record being the parent's response and the n+1 the Childs. The
> simple, how often do the parents and children have the same
response? I have
> used a crude approach by splitting the data into a parents and
> set, merging them and then comparing the responses.
> Is there a more "elegant" or efficient approach using loops. I have
> tried using foreach with no success. I am using Stata 8.
I doubt that this needs loops at all.
One approach is to -reshape-. That has several advantages.
Otherwise, keeping the same data structure, let's suppose that we
have an indicator of parent-or-child which is say
. gen porc = mod(_n,2)
For any variable, the difference parent - child
. gen diff = var - var[_n+1] if porc
and so the same response on that variable implies
-diff- being 0.
. count if diff = 0
If "response" means similarity on several variables,
then use -duplicates- to look at duplicates
in terms of a family code and those other variables.
* For searches and help try: