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

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

From |
"Heidi M Pitts" <hpitts@unm.edu> |

To |
statalist@hsphsun2.harvard.edu |

Subject |
st: Using a loop to calculate vector differences |

Date |
Thu, 20 Sep 2012 15:45:36 -0600 |

Hi listers, Can anyone help fix my code for the following issue: I have two vectors: M=[0, 0, 0, 0, 0, 0, 0, .1, .4, .4, .1] F=[0, 0, 0, 0, 0, .05, .3, .6, .05, 0, 0] so n=11 obs for each vector.

set matsize 100 mkmat x_male mkmat y_female mkmat y_fem_inv set obs 11 gen n=_n gen diff=. mkmat diff forvalues i=1(1)11 { gen y=x_male`i'-y_female replace diff=y if `i'< n } /*****************************************/ Thanks for any help! Sincerely, Heidi M. Pitts Graduate Student Department of Economics University of New Mexico * * 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 a loop to calculate vector differences***From:*Nick Cox <njcoxstata@gmail.com>

- Prev by Date:
**Re: st: outsheet throws away varnames in unix** - Next by Date:
**Re: st: Chi2 test on weighted data** - Previous by thread:
**st: outsheet throws away varnames in unix** - Next by thread:
**Re: st: Using a loop to calculate vector differences** - Index(es):