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 at the end of May, and its replacement, statalist.org is already up and running.


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

Re: st: grouping cases


From   "Yang, Chongmin" <chongminyang@gmail.com>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: grouping cases
Date   Sat, 8 Oct 2011 08:25:11 +0900

Thanks, Daniel.
I think your method is more convenient.

2011/10/8 daniel klein <klein.daniel.81@googlemail.com>:
> 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
> variable.
>
> . 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".
>
> Best
> Daniel
>
> --
>
> 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:
> *   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/


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