Bookmark and Share

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, is already up and running.

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

Re: st: grouping cases

From   daniel klein <>
Subject   Re: st: grouping cases
Date   Fri, 7 Oct 2011 22:37:34 +0200

Maybe working with numeric variables might be more convenient here.
Assuming that there are no typing errors in "country" you can fristly
-encode- this variable.  You then create the dummy using a numeric

. encode country ,g(cntry)
. la li cntry
. g oecd = inrange(cntry, 1, 5) | inrange(cntry, 12, 14) ...
[fictional numbers !]

For the second step you may also use -todummy- ,(available from SSC).
The syntax would then be something like

. todummy mk ,v(1/5 12/14) g(oecd)

Even if you cannot use -inrange()- or the like, I guess it is still
more convenient to write "12" instead of writing "Korea, Republic of".



I want to choose oecd members from all countries and make dummy variables.
So I wrote like this way:

gen oecd=1 if country=="Australia" | country=="Austria" |
country=="Belgium" | country=="Canada" |
*   For searches and help try:

© Copyright 1996–2015 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index