Bookmark and Share

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, is already up and running.

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

Re: st: For each observation, total values

From   Nick Cox <>
Subject   Re: st: For each observation, total values
Date   Tue, 5 Jul 2011 18:19:53 +0100

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


On Tue, Jul 5, 2011 at 5:51 PM, Zach Levin <> 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:

© Copyright 1996–2015 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index