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: How to use an independent grid to perform calculations for each observations

From   Daniel Almar de Sneijder <>
Subject   st: How to use an independent grid to perform calculations for each observations
Date   Wed, 10 Oct 2012 15:21:36 -0400

Hello Stata,

Does anybody perhaps know a way to perform calculations for each
observant using a grid. More specific,

I have variables that record the earnings of respondents, say
RwIEARN50 ... RwIEARN99.
I want to index these variables by using a grid. The trick is however
that each observation refers to respondents. Each respondent has a
different year of birth and year of eligibility and therefore a
different indexing factor needs to be used.

So basically I have a N-by-M matrix, call it S, with on the rows the
indexing factor of the earnings at each year i = 1,...,N and on the
columns the year eligibility j = 1,...,M

Now I want to construct variables RwINDEX50 ... RwINDEX99 that record
the indexing factor for all respondents 1....R (rows), which basically
depend on the year of eligibility of each respondent and the name of
the variable (50...99).

In formula, this would correspond to:

year of eligibility = date of birth of `r' + 62
replace RwINDEX`year'[`r'] = S[`year']['year of eligibility']

Basically this is something very simpel that can be done within 5
minutes with Matlab. In STATA however this looks like impossible?

Thank you for the input.

*   For searches and help try:

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