Bookmark and Share

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: grouping cases


From   Nick Cox <[email protected]>
To   [email protected]
Subject   Re: st: grouping cases
Date   Sat, 8 Oct 2011 16:35:57 +0100

Daniel's method is quicker, but your original method has the advantage
that it's easier to see what you did in a log file kept as an audit of
your analysis. If you made a mistake in writing down the integer
codes, it would be harder to spot.

Nick

On Sat, Oct 8, 2011 at 12:25 AM, Yang, Chongmin <[email protected]> wrote:
> Thanks, Daniel.
> I think your method is more convenient.
>
> 2011/10/8 daniel klein <[email protected]>:
>> 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/


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