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


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

st: simple calculations across rows


From   "B. Timothy Walsh" <btw1@columbia.edu>
To   statalist@hsphsun2.harvard.edu
Subject   st: simple calculations across rows
Date   Mon, 16 Jul 2012 10:37:15 -0400

Hello!
I am a beginner-to-intermediate level STATA user, and would like to find a solution to what I hope is a relatively straightforward problem. I have looked a bit at the archives, and have been led in the direction of mata, but am wondering if another (less daunting?) method might be available.

I am importing data from a device and would like to use STATA to do some data reduction. The device monitors types of physical activity over 2 days, and the data are provided in rows, each of which contains a summary of data over pre-defined 4 hour blocks, like 8 AM to 12N. So, each subject has 6 rows of data/day and a total of 12 rows for 2 days.

What I wish to do is to be able to summarize--like simple averages, etc.--across some but not all time periods, and, maybe, days. For example, for each subject, calculate the total activity over the 8AM to 4PM blocks on day 1 and compare that to the same measure on day 2. Etc.

Here is a somewhat simplified outline of how one subject's data might look for the first 3 periods of day 1:

ID	DAY		PERIOD	MEASURE
i	1		1		Xi11
i	1		2		Xi12
i	1		3		Xi13

I have only a modest dataset, so I do not need particularly efficient code. Better code that is easy to interpret and be modified by a novice such as myself.

Thank you for any guidance!
Tim Walsh

*
*   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   |   Site index