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

From |
Kit Baum <baum@bc.edu> |

To |
statalist@hsphsun2.harvard.edu |

Subject |
Re: st: using vector notation to simplify coding |

Date |
Wed, 12 Aug 2009 10:33:38 -0400 |

<>

clear mata:mata clear set obs 100

forvalues i = 1/6 { gen ing_`i' = 100000 * runiform() gen mes_`i' = round((runiform()*(6-1))+1) } su ing* forv i=1/6 { local ingl "`ingl' ing_`i'" local mesl "`mesl' mes_`i'" } mata // fill in with deflators for each calendar month def = ( 1, 1.1, 1.2, 1.3, 1.4, 1.3, 1.2, 1.1, 1, 1.1, 1.2, 1.3) st_view(Y=., ., st_local("ingl")) st_view(M=., ., st_local("mesl")) for(j=1;j<=rows(Y);j++) { for(i=1;i<7;i++) { Y[j,i] = Y[j,i] :/ def[M[j,i]] } } end su ing* Kit Baum | Boston College Economics & DIW Berlin | http://ideas.repec.org/e/pba1.html

An Introduction to Modern Econometrics Using Stata | http://www.stata-press.com/books/imeus.html On Aug 12, 2009, at 02:33 , Dan wrote:

I have data in monthly expenditures in variables ing_1 throughing_6, and survey months in variables mes_1 through mes_6 (thesevary from respondent to respondent). I wish to adjust the monthlyexpenditures for inflation, and I have deflation factors invariables def_1 through def_12.I am pretty accomplished in SAS, but only a novice in Stata. In SASI would say:array def {12} def_1 - def_12; array ing {6} ing_1 - ing_6; array mes {6} mes_1 - mes_6; do t=1 to 6; month=mes{t}; ing{t}=ing{t}/def{month}; end;

* * 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/

**Follow-Ups**:**Re: st: using vector notation to simplify coding***From:*Dan Waldo <dwaldo@aresearch.com>

- Prev by Date:
**st: AW: Problems with outreg2 after xtlogit** - Next by Date:
**st: AW: AW: Problems with outreg2 after xtlogit** - Previous by thread:
**Re: st: using vector notation to simplify coding** - Next by thread:
**Re: st: using vector notation to simplify coding** - Index(es):

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