Statalist


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

st: egen(mean or suchlike) for a string variable


From   joe j <joe.stata@gmail.com>
To   statalist@hsphsun2.harvard.edu
Subject   st: egen(mean or suchlike) for a string variable
Date   Thu, 8 Oct 2009 11:57:16 +0200

In my data I have a string variable "University", which lists
university names. In some years the names are missing. Two other
variables I've are "Professor" and "Year". The same "Professor" and
"University" can occur multiple times in a year.

The problem I have is that there are quite a few University names that
are missing. What I want to do is to replace as many missing
University names as possible, by assuming that: when a professor is
linked to a university at least once in a year, she is linked to the
same university during that year - so the missing university name when
her name occurs again in the same year can be replaced (why there are
missing university names is a complicated story:)).

 Any suggestion would be appreciated.

Best,
JJ

I tried the following in Stata (it's foolish, I know):

  bysort year professor: egen University_all=mean(University)

But I get the warning "type mismatch".
*
*   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/



© Copyright 1996–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index