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: Category sizes in IF statements - how?
From 
 
Alan Neustadtl <[email protected]> 
To 
 
[email protected] 
Subject 
 
Re: st: Category sizes in IF statements - how? 
Date 
 
Mon, 28 Feb 2011 13:53:29 -0500 
Here is one possible solution:
encode author, gen(author1)
bysort author1: egen authorcnt=count(author1)
gen dummieslab=.
replace dummieslab=0 if author<=20
replace dummieslab=1 if author>20
Best,
Alan
On Mon, Feb 28, 2011 at 1:41 PM, Jan Fredrik Hovden <[email protected]> wrote:
> Is there a simple way to use the size of a category as a condition of an IF statement?
>
> Take for example the variable AUTHOR, which includes about 1000 different authors. I would like to make a dummy for some of these authors (using either TAB,GEN() or DUMMIESLAB - but not for everyone, only for categories including at least 40 persons.
>
> IN OTHER  WORDS: What I would like is to do something like this (written in English):
>
> . dummieslab AUTHOR if categorysize>20
>
> I would greatly appreciate any idea f.
>
> Jan Fredrik Hovden
> Associate professor, Department of Information and Media Science
> University of Bergen, Norway
> *
> *   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/