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 |
Kari Hexem <khexem@gmail.com> |

To |
statalist@hsphsun2.harvard.edu |

Subject |
st: Combinations of 3 |

Date |
Sun, 19 Dec 2010 19:03:26 -0500 |

Hi, I would like to sum the numbers of variable v with 6 other variables: n1, n2, n3, n4, n5, n6, in combinations of 3. So the results would be the sums of the following variables, identified using 15 combinations (6 choose 2), or, to spell it out, the sums of each of these following possibilities: v-n1-n2 v-n1-n3 v-n1-n4 v-n1-n5 v-n1-n6 v-n2-n3 v-n2-n4 v-n2-n5 v-n2-n6 v-n3-n4 v-n3-n5 v-n3-n6 v-n4-n5 v-n4-n6 v-n5-n6 I can get the sum of the first two of the 3 variables by using the following code: forvalues i=1(1)6 { gen sum`i' = v + n`i' } but I can't figure out how to add in the 3d variable, which can't be a repeat of the 2nd variable (ie. v-n1-n1 is not allowed). Thoughts? I feel like it should have something to do with nested loops, or the -selectvars- command, but I am totally stuck. Any help would be greatly appreciated. Thanks, Kari * * 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: Combinations of 3***From:*Tirthankar Chakravarty <tirthankar.chakravarty@gmail.com>

- Prev by Date:
**Re: st: A way to capture the size of a file being used** - Next by Date:
**Re: st: Combinations of 3** - Previous by thread:
**st: Suppress labeling of categorical axis values in graph bar/hbar** - Next by thread:
**Re: st: Combinations of 3** - Index(es):