Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.


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

Re: st: For each observation, total values


From   Zach Levin <[email protected]>
To   [email protected]
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" <[email protected]>
To: [email protected]
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 <[email protected]> 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/


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index