Notice: On March 31, it was **announced** that Statalist is moving from an email list to a **forum**. The old list will shut down at the end of May, and its replacement, **statalist.org** is already up and running.

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

From |
Nick Cox <njcoxstata@gmail.com> |

To |
statalist@hsphsun2.harvard.edu |

Subject |
Re: st: How to use an independent grid to perform calculations for each observations |

Date |
Wed, 10 Oct 2012 21:52:26 +0100 |

The Stata way is not necessarily the MATLAB way, fine program though that is. (Not STATA and Matlab!) I don't understand all of this but nevertheless will make a guess. You have say 50 variables and you want say 50 more variables. Creating such a large extra batch only raises the question of how you are going to work with all those extras. Do you have a plan for that? And with other such batches of extras you might create for each related problem. The clue is that they are all variables of the same kind. Normally that implies a loop over variables, but if you restructure you may be able to avoid such a loop. It's more likely that you need to -reshape long- and then work with far fewer variables. If you don't get a better answer than this, I would post a very simple analogue of your problem showing numbers. Nick On Wed, Oct 10, 2012 at 8:21 PM, Daniel Almar de Sneijder <dasneijder@gmail.com> wrote: > 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? * * For searches and help try: * http://www.stata.com/help.cgi?search * http://www.stata.com/support/faqs/resources/statalist-faq/ * http://www.ats.ucla.edu/stat/stata/

**References**:**st: How to use an independent grid to perform calculations for each observations***From:*Daniel Almar de Sneijder <dasneijder@gmail.com>

- Prev by Date:
**Re: st: unrar - unzipfile** - Next by Date:
**st: Stata agent string for net install** - Previous by thread:
**st: How to use an independent grid to perform calculations for each observations** - Next by thread:
**st: Stata agent string for net install** - Index(es):