Thank you, this solution works for numeric variables. Do you have any
suggestions for strings?
Friedrich
On 7/27/07, Jeph Herrin <[email protected]> wrote:
> Why not
>
> . egen rowmin=rowmin(var1 var2 ... varN)
> . egen rowmax=rowmax(var1 var2 ... varN)
> . gen tag=rawmax!=rowmin
>
> ? -rowmin- and -rowmax- ignore missing values.
>
> hth,
> Jeph
>
> Friedrich Huebler wrote:
> > I would like to compare a set of variables and tag those that do not
> > contain the same values. Missing values should be ignored. -egen
> > newvar = diff(varlist)- is not an option because it does not skip
> > missing values. The last command in the example below works but it
> > becomes impractical with a longer list of variables.
> >
> > . sysuse auto
> > . gen mpg2 = mpg if foreign==0
> > . gen mpg3 = mpg if foreign==1
> > . replace mpg3 = mpg+1 if rep78==2
> > . egen tag = diff(mpg mpg2 mpg3)
> > . gen tag2 = (mpg!=mpg2 & mpg<. & mpg2<. | mpg!=mpg3 & mpg<. & mpg3<.
> > | mpg2!=mpg3 & mpg2<. & mpg3<.)
> >
> > The -egen- command tags all observations, the -gen- command only those
> > that I expect to be tagged. Are there better solutions that can also
> > be used with ten or more variables?
> >
> > Friedrich
*
* 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/