Statalist


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

st: data management


From   "Sim.Oertel@t-online.de" <Sim.Oertel@t-online.de>
To   statalist@hsphsun2.harvard.edu
Subject   st: data management
Date   Mon, 07 Dec 2009 15:56:38 +0100

Dear all,
I have a quick data management question. I would like to count the number of different values over several variables within a row and save the result in a new variable.

For example: 
Var1 Var2 Var3 Var4 Var5 Var6 Var7 Varx
1         2      3        9       20     1       1      ...

In the example above, the new variable would holds the value 5, since Var1, Var6 and Var7 all hold the same value (put differently, 5 different values can be count over var1 - var7). 

I tried the following command: egen byte countdif = diff(var1 var2 var3 var4 var5 var6 var7 varx). However, the new variable is only a dummy (0/1). 

I bet there is a very simple solution ? however I am too blind to see it?

I appreciate any help and suggestions.
Thanks
Simon



*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/



© Copyright 1996–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index