Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at

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

RE: st: replacing with mean

From   Nick Cox <>
To   "''" <>
Subject   RE: st: replacing with mean
Date   Thu, 2 Dec 2010 19:04:33 +0000

One of my posts earlier today gave an example of the use of -foreach- and a pointer to an article on it. 


Fabio Zona

Thanks a lot to both Dimitry and Nick.

Last issue:  I have read the FAQ. However, it is just for one variable: how should I implement the commands when I have 20 or more different  variables? I am facing difficulties in writing the lines!!

Da: "Nick Cox" <>

This is an FAQ. 

FAQ     . . Creating variables recording prop. of the other members of a group
        . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  N. J. Cox
        4/05    How do I create variables summarizing for each
                individual properties of the other members of a

Fabio Zona

my request for "replace missing" was related to a more complex procedure I am trying to define. I think I better describe the whole problem and ask you for a more general and maybe effective solution.

Here is the problem.

Say I have 200 industries. I have a list of companies, List"A", of say 5000 companies distributed among these industries. For each of these companies I have 20 variables. 

Industry   List"A"    Var1   Var2  Var3   
A             1        
A             2
A             3

I have a separate list, List"B" of 700 companies, that is a subsample of List"A". 

I need to associate to each company "i" of List"B" (my sample for regression) the median value of its industry EXCLUDING the focal company "i", and have to do this for all 20 variables!

It's extremely challenging. How would you deal with this?

*   For searches and help try:

© Copyright 1996–2017 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index