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 |
"Nick Cox" <n.j.cox@durham.ac.uk> |

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

Subject |
RE: st: How to make a code faster - alternatives to egen var = concat(vars) ?, |

Date |
Thu, 17 Jun 2010 22:02:51 +0100 |

I'll -collapse- and -merge- back again. Nick n.j.cox@durham.ac.uk Tiago V. Pereira Thank you so much again, Antoine! Yes, this is a very efficient way! However, I could not figure out how I can save the combination of the categorical variables that a specific meanX refers to. For example, the commands sysuse auto, clear bysort foreign rep78 : mymean price scalar dir show a list of scalars containing the mean of the ith combination, but I don't know if the mean10 refers to the combination "foreign = Foreign, rep78 =4" or "foreign = Foreign, rep78 = 5" [Actually I do in this specific case if I take a look at each value from the output.] Nevertheless, assuming a very large number of categorical variables (n>10), I cannot write a loop and say that mean2451 refers to the combination x1==0 x2==0 x3==2 x4==0 x5==2 and x6==1. I want to summarize the mean of this combination in group 1 and generate a separate variable for group 2. for example bysort x1 x2 x3 x4 x5 x6 : mymean score if group==1 */ yes, -mymean- needs further amendments to have this option replace score = mean2451 if group==2&x1==0&x2==0&x3==2&x4==0&x5==2&and&x6==1 So, In this case I know that mean2451 comes from the combination x1==0&x2==0&x3==2&x4==0&x5==2&and&x6==1 from group 1 and I replace its value for all subjects from group 2 having an identical combination. This is getting tough, but you have any additional tips, I will be really very grateful! * * 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/

**References**:**Re: RE: st: How to make a code faster - alternatives to egen var = concat(vars) ?,***From:*"Tiago V. Pereira" <tiago.pereira@mbe.bio.br>

**Re: st: How to make a code faster - alternatives to egen var = concat(vars) ?,***From:*Antoine Terracol <terracol@univ-paris1.fr>

**Re: st: How to make a code faster - alternatives to egen var = concat(vars) ?,***From:*"Tiago V. Pereira" <tiago.pereira@mbe.bio.br>

- Prev by Date:
**Re: st: Identifying unique values with codebook** - Next by Date:
**Re: st: How to make a code faster - alternatives to egen var = concat(vars) ?,** - Previous by thread:
**Re: st: How to make a code faster - alternatives to egen var = concat(vars) ?,** - Next by thread:
**Re: st: How to make a code faster - alternatives to egen var = concat(vars) ?,** - Index(es):