Bookmark and Share

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

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

st: For each observation, total values

From   Zach Levin <>
Subject   st: For each observation, total values
Date   Tue, 5 Jul 2011 09:51:37 -0700 (PDT)


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.

Any ideas?


Zach Levin
Stanford University School of Medicine

*   For searches and help try:

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