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

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

From |
Christopher Baum <kit.baum@bc.edu> |

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

Subject |
st: re: Re: forvalues, panel data |

Date |
Fri, 1 Oct 2010 21:47:14 -0400 |

<> Nick said I certainly agree with Kit that a -merge- with a file with coefficients is another way to do it, and one worth knowing about. But I can't see it's less error-prone. Either way, someone has to type the numbers in or read them from somewhere else and there is equal scope for error so far as I can see. Nick Cox > Your -forvalues- scaffolding is completely redundant, and in fact causes the same changes to be executed 11 times. But your problem does call for a loop over a varlist. > > foreach v of var <whatever> { > gen d`v' = . > replace d`v' = `v' if fyear == 1980 > replace d`v' = `v' * 0.967059 if fyear == 1981 > <etc> I respectfully disagree with Nick's assessment of relative risk. When one types (or copy/pastes) a large number of statements such as replace d`v' = `v' * 0.967059 if fyear == 1981 it takes some concentration to pick up the next number from the deflator series AND attach it to the correct year. This requires a lot of typing, or copy/pasting, and most would agree that after you copy/paste the same line 20 times and then make two manual edits on each line, Pr[accuracy] < 1. Putting those values in a file will, for instance, allow -merge- to squawk if you make the mistake of repeating a year, or leaving a year out, of the auxiliary file; that will either cause a m:1 merge to fail or leave some years in the panel data unmatched, either of which can readily be caught. You can also tsset and -tsline deflator- on the auxiliary file, before merging, to see whether the values are reasonably smooth, as they should be for a deflator. Furthermore, in cases where there might be alternative price deflator series (e.g. PCE deflator vs. CPI) to be considered, it is easy to add them to the auxiliary file, and just change one line that does the deflation. The explicit 'replace .. if' method would require manual adjustment for every data value of the alternate series. Kit Kit Baum | Boston College Economics & DIW Berlin | http://ideas.repec.org/e/pba1.html An Introduction to Stata Programming | http://www.stata-press.com/books/isp.html An Introduction to Modern Econometrics Using Stata | http://www.stata-press.com/books/imeus.html * * 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**:**st: RE: re: Re: forvalues, panel data***From:*Nick Cox <n.j.cox@durham.ac.uk>

**st: RE: re: Re: forvalues, panel data***From:*"Biljana Dlab" <dlab@isb.uzh.ch>

- Prev by Date:
**st: re: vif after newey2** - Next by Date:
**st: st : regress problem** - Previous by thread:
**st: re: vif after newey2** - Next by thread:
**st: RE: re: Re: forvalues, panel data** - Index(es):