Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: vectored data

From   Kit Baum <>
Subject   st: vectored data
Date   Mon, 3 Oct 2005 09:46:23 -0400

Maarten said

forvalues i = 1/n {
gen vol`i' = length`i' * breadth`i' * height`i' * _pi / 6

The problem is that this measurement is performed a number of
times for each mouse on different days so that I'd need
breath1... etc.

gen volumem=lengthm*.....

What you are describing is a relational database in which the fixed characteristics of each mouse are stored in each table, with a mouse_id identifying them, and another table in which you have the time-varying measurements (perhaps weight of the mouse or how much it ate today), again identified with mouse_id and some kind of timestamp. In a RDBMS you would then join those two tables when you needed to juxtapose all of the characteristics. In Stata terms, that would suggest

mouse1.dta : mouse_id length breadth height birth_date blood_type

mouse2.dta: mouse_id timestamp weight amount_consumed

Then any time you want to combine the two tables you just merge them:

use mouse2
merge using mouse1, uniqusing

which appends the fixed characteristics to each record in the time- varying dataset.

See my FAQ about appending group characteristics to individual level data. This is essentially the same problem: for group read mouse and individual read mouse-measured-at-time-t.

Kit Baum, Boston College Economics

* For searches and help try:

© Copyright 1996–2017 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index