Statalist


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

st: RE: Re: sum across observations until a certain cutpoint


From   "Nick Cox" <n.j.cox@durham.ac.uk>
To   <statalist@hsphsun2.harvard.edu>
Subject   st: RE: Re: sum across observations until a certain cutpoint
Date   Sun, 9 Nov 2008 17:59:13 -0000

Still not very clear to me, but I guess something like this 

task1 task2 task3  task4  task5 
20      10    20    5       10 
5       10    15    30      2 
100     2      3    3       4 

So that the three individuals above had completed 4, 4, 0 tasks in the
first 60 seconds. 

How many within 60 seconds?  

gen cumul = 0 
gen within60 = 0 

qui forval i = 1/5 { 
	replace cumul = cumul + task`i' 
	replace within60 = `i' if cumul <= 60 
} 

Nick 
n.j.cox@durham.ac.uk 

Amanda Botticello PhD, MPH

IT's a "wide" dataset...subjects completed up to 200 items in a task,
and we recorded the number of seconds it took to complete each item.  I
can create a sum of the total number of items completed and total time;
now I want to find out how many items each individual completed in 60,
90, and 120 seconds.  Does that help?

>>> "Martin Weiss" <martin.weiss1@gmx.de> 11/9/2008 11:00 AM >>>

Well, if you want the running sum, look at -help sum()-. But maybe you
could 
give us a peek at your data structure, that would assist in answering
your 
question...

"Amanda Botticello" <abotticello@kmrrec.org>

>I have a dataset of test items and the time (in seconds)to complete
each 
>item.  I need to create a variable that sums the time variables up to a

>certain number -- i.e., 60, 90, 120 seconds.  Is there a way I can use
the 
>egen newvar = rowtot (time*) command to count up to 60 seconds, etc?

*
*   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–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index