Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: st: Combinations of 3
From
Kari Hexem <[email protected]>
To
[email protected]
Subject
Re: st: Combinations of 3
Date
Sun, 19 Dec 2010 19:29:00 -0500
Thank you! It worked!!
On Sun, Dec 19, 2010 at 7:16 PM, Tirthankar Chakravarty
<[email protected]> wrote:
> ******************************************
> // generate some data
> clear
> set obs 100
> g v = runiform()
> forv i=1/6{
> g n`i' = runiform()
> }
> // sum variables
> forv i=1/5 {
> forv j = `=`i'+1'/6 {
> g v_n`i'_n`j' = v + n`i' + n`j'
> }
> }
> su
> ******************************************
>
> T
> On Sun, Dec 19, 2010 at 4:03 PM, Kari Hexem <[email protected]> wrote:
>> 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/
>>
>
>
>
> --
> To every ω-consistent recursive class κ of formulae there correspond
> recursive class signs r, such that neither v Gen r nor Neg(v Gen r)
> belongs to Flg(κ) (where v is the free variable of r).
>
> *
> * 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/
>
*
* 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/