[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

From |
baum <baum@bc.edu> |

To |
statalist@hsphsun2.harvard.edu |

Subject |
st: Re: macros |

Date |
Fri, 26 Jul 2002 09:05:58 -0400 |

--On Friday, July 26, 2002 2:33 -0400 Chris wrote:

Look at any ADO file that does the kind of thing you're interested in. There are also a number of FAQs that use macros in illustrating various points.i'm trying to figure out the macro basics & can't seem to find any simple examples on the web or in the manual. if someone could please post the text of a simple *.do file that uses macros, i'd really really appreciate it. i'm using stata 7. i'd also really appreciate any suggestions on my specific problem that i'm trying to solve w/ macros: to take variables (air_reg1, air_reg2, ..., air_reg24) and (voc_reg1, ..., voc_reg24) and to produce the sum of the products: air_reg1*voc_reg1 + air_reg2*voc_reg2 + ... + air_reg24*voc_reg24 for a bunch of different sets of variables ({air,voc} is one example) w/ a large dataset.

For the sort of thing you're talking about, Nick Cox' Speaking Stata columns in Stata Journal would be a very useful reference. Generally speaking, the Programming manual is a very good thing to have; if you only have the Users' Guide and Ref Man available, you should see about getting a copy of [P] (available a la carte from the Stata Bookstore, or the Stata GradPlan if U.Chicago participates).

For what you describe try

gen result = 0

forvalues i=1/24 {

replace result = result + air_reg`i' * voc_reg`i'

}

If the air and voc variables are doubles, make result a double as well.

Kit

*

* For searches and help try:

* http://www.stata.com/support/faqs/res/findit.html

* http://www.stata.com/support/statalist/faq

* http://www.ats.ucla.edu/stat/stata/

- Prev by Date:
**st: Re: STB archive maintenance** - Next by Date:
**Re: st: Problem with wstata.exe** - Previous by thread:
**st: Re: STB archive maintenance** - Next by thread:
**st: Overdispersed Poissons** - Index(es):

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