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

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

From |
Zach Levin <zlevin@stanford.edu> |

To |
statalist@hsphsun2.harvard.edu |

Subject |
Re: st: For each observation, total values |

Date |
Tue, 5 Jul 2011 13:44:37 -0700 (PDT) |

That was perfect. Thank you! ----- Original Message ----- From: "Nick Cox" <njcoxstata@gmail.com> To: statalist@hsphsun2.harvard.edu Sent: Tuesday, July 5, 2011 10:19:53 AM Subject: Re: st: For each observation, total values We can't comment on your code because you don't give any. The -egen- function -anycount()- appears to be what you want. If your real question is how it works you can inspect its insides by e.g. . viewsource _gcount.ado Nick On Tue, Jul 5, 2011 at 5:51 PM, Zach Levin <zlevin@stanford.edu> wrote: > I have month variables that can take on different values for each month, that is MONTH_1 might be equal to 0 while MONTH_3 might be equal to 1. What I would like to do is create a loop that generates a variable equal to the number of months where the value equals 1 (or 0 or 3 etc). The problem is, every time I create a loop it replaces the value for ALL the observations, but I really just want to know for each observation how many months the value is set to a certain number. * * 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/

**References**:**Re: st: For each observation, total values***From:*Nick Cox <njcoxstata@gmail.com>

- Prev by Date:
**st: calculate gains and losses from stock prices** - Next by Date:
**Re: st: Analysis of experiment involving baseline measurements** - Previous by thread:
**Re: st: For each observation, total values** - Next by thread:
**st: Re: Stata code for calculating Zivot-Andrews unit root test in presence of structural break** - Index(es):