Statalist


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

AW: st: data management


From   "Martin Weiss" <martin.weiss1@gmx.de>
To   <statalist@hsphsun2.harvard.edu>
Subject   AW: st: data management
Date   Mon, 7 Dec 2009 16:02:54 +0100

<> 



*************
egen, group()
*************

does not support -by-, though...


HTH
Martin


-----Ursprüngliche Nachricht-----
Von: owner-statalist@hsphsun2.harvard.edu [mailto:owner-statalist@hsphsun2.harvard.edu] Im Auftrag von Ulrich Kohler
Gesendet: Montag, 7. Dezember 2009 16:04
An: statalist@hsphsun2.harvard.edu
Betreff: Re: st: data management

I would use egen-group in the long format for this:

. gen index = _n
. reshape long Var, i(index)
. egen countdif = group(Var), by(index)
. reshape long 

Many regards
Uli

Am Montag, den 07.12.2009, 15:56 +0100 schrieb Sim.Oertel@t-online.de:
> 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/



*
*   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/


*
*   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