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

From |
Dan Waldo <dan_waldo@yahoo.com> |

To |
statalist <statalist@hsphsun2.harvard.edu> |

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

Date |
Wed, 12 Aug 2009 06:34:09 -0700 (PDT) |

Thanks to Martin and Michael for their kind replies. The data I am using come from the 2008 Mexican Encuesta Nacional de Ingresos y Gastos de los Hogares ENIGH). Households are interviewed for 6 months in staggered panels, reflected in the values assigned to variables mes_1 through mes_6, e.g. mes_1 Freq. Value 11576 7 34660 8 36142 9 27163 10 23731 . For a panel first interviewed in February, the values of mes_1 through mes_6 are +-----------------------------------------------+ mes_1 mes_2 mes_3 mes_4 mes_5 mes_6 ----------------------------------------------- 1. 7 6 5 4 3 2 +-----------------------------------------------+ To adjust the monetary figures reported in each month (ing_1 through ing_6) for the effects of inflation, I have a vector of scalars that represent consumer prices (where August is the numeraire), e.g., scalar jul08=0.9942 scalar ago08=1.0000 scalar sep08=1.0068 scalar oct08=1.0136 So, if mes_1 were 7, I would divide the value in ing_1 by the July scalar 0.9942; if mes_1 were 10, I would divide by 1.0136 I suppose that I could write .replace ing_1=ing_1/def_7 if mes_1==7 .replace ing_1=ing_1/def_8 if mes_1==8 .replace ing_1=ing_1/def_9 if mes_1==9 .replace ing_1=ing_1/def_10 if mes_1==10 .replace ing_2=ing_2/def_6 if mes_1==6 .replace ing_2=ing_2/def_7 if mes_1==7 .replace ing_2=ing_2/def_8 if mes_1==8 .replace ing_2=ing_2/def_9 if mes_1==9 etc but this seems so bulky and inelegant -- and this is where I thought a vector notation would help ... but Michael, if I understand his response correctly, feels that a loop of the sort replace ing_`t'=ing`t'/DEF[mes_`t'] isn't going to happen. Martin, does this clarify my question? Dan --- On Tue, 8/11/09, Dan Waldo <dan_waldo@yahoo.com> wrote: > From: Dan Waldo <dan_waldo@yahoo.com> > Subject: using vector notation to simplify coding > To: "statalist" <statalist@hsphsun2.harvard.edu> > Date: Tuesday, August 11, 2009, 9:58 AM > Dear Statalist members, > > I have data in monthly expenditures in variables ing_1 > through ing_6, and survey months in variables mes_1 through > mes_6 (these vary from respondent to respondent). I wish to > adjust the monthly expenditures for inflation, and I have > deflation factors in variables def_1 through def_12. > > I am pretty accomplished in SAS, but only a novice in > Stata. In SAS I 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; > > I have been searching unsuccessfully for the Stata analogue > to this; I am sure it is written somewhere and I am just not > using the best search terms. > > Will somebody please point me to the proper place? > > Thanks! * * 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: Re: using vector notation to simplify coding***From:*Maarten buis <maartenbuis@yahoo.co.uk>

- Prev by Date:
**st: RE: Date: Wed, 12 Aug 2009 09:02:06 -0400 (and matrix labels)** - Next by Date:
**Re: st: Re: using vector notation to simplify coding** - Previous by thread:
**st: how to reset row / column equations from a matrix** - Next by thread:
**Re: st: Re: using vector notation to simplify coding** - Index(es):

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