Statalist


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

Re: st: using vector notation to simplify coding


From   "Nick Cox" <n.j.cox@durham.ac.uk>
To   <statalist@hsphsun2.harvard.edu>
Subject   Re: st: using vector notation to simplify coding
Date   Wed, 12 Aug 2009 21:34:08 +0100

This generated a lively and continuing discussion. This is just to point
out that -search array- points to an FAQ by William Gould. I suspect
that if he were writing that now he would say less about -while- and
more about -forvalues-. 

Nick 
n.j.cox@durham.ac.uk 

Dan Waldo

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.


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



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