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


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

Re: st: grouping cases


From   Nick Cox <njcoxstata@gmail.com>
To   statalist@hsphsun2.harvard.edu
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 <chongminyang@gmail.com> wrote:
> 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/


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