Notice: On March 31, it was **announced** that Statalist is moving from an email list to a **forum**. The old list will shut down at the end of May, and its replacement, **statalist.org** is already up and running.

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

From |
Nick Cox <njcoxstata@gmail.com> |

To |
"statalist@hsphsun2.harvard.edu" <statalist@hsphsun2.harvard.edu> |

Subject |
Re: st: How can I count the number of variables that meet a certain condition per observation? |

Date |
Sun, 4 Dec 2011 13:18:53 +0000 |

Your questions change from post to post....

Nick On 4 Dec 2011, at 12:50, "Schreck, Philipp" <schreck@bwl.lmu.de> wrote:

Hi Daniel,Thank you very much for your help. Sorry for not having found thecorresponding text via the -help- function before. I actually neededboth, counting the number of variables with value "2":egen var1 = anycount(var_101-var_110), values(2)and computing the sum across these variables (sorry for theimprecise question).Thanks & greetings, Philipp ------------------------------ Date: Sat, 3 Dec 2011 13:18:57 +0100 From: daniel klein <klein.daniel.81@googlemail.com>Subject: Re: st: How can I count the number of variables that meet acertain condition per observation?Phillip "would like to count for each observation the number of variables that meet a certain condition, say var*==2."The very first function in -help egen- is -anycount()- and isdescribed as:"It returns the number of variables in varlist for which values are equal to any integer value in a supplied numlist. [...] Also see anyvalue(varname) and anymatch(varlist)." However, I am not sure I am getting the problem, because "[...] computing the sum across variables (for each observation) ONLY for those variables with values greater than 1" to me means something comletely different and is not at all "[...] alternatively, [...]" to "the number of variables with values greater than 1 per

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

**References**:**Re: st: How can I count the number of variables that meet a certain condition per observation?***From:*"Schreck, Philipp" <schreck@bwl.lmu.de>

- Prev by Date:
**st: AW: Good book for multilevel Modelling and Survival analysis** - Next by Date:
**Re: st: How can I count the number of variables that meet a certain condition per observation?** - Previous by thread:
**Re: st: How can I count the number of variables that meet a certain condition per observation?** - Next by thread:
**Re: st: How can I count the number of variables that meet a certain condition per observation?** - Index(es):