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: bysort, forvalues and _N

From   Constantin Alba <>
Subject   st: bysort, forvalues and _N
Date   Fri, 25 Jan 2013 21:38:22 +0200

Dear statlist members,

I am trying to find a solution for the following problem.

I have a dataset organized by personID, for each personID there are
startDate and Duration for various activities.

I want to find out how many activities a person performs at the same
time (e.g. something like workload)

logically i see it like this:

sort personID startDate Duration

by personID: forvalues i=1/`=_N' {
                                   "compare current date with all
other prior dates+duration
                                       and update counter accordingly"

however, by and forvalues do not work together, so i am trying to find
an alternative way to do so.

thank  you in advance

*   For searches and help try:

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