Statalist


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

Re: st: Encode generates a wrong list


From   "Martin Weiss" <[email protected]>
To   [email protected]
Subject   Re: st: Encode generates a wrong list
Date   Wed, 30 Dec 2009 01:03:57 +0100

<>

As the manual [D], p.165, says: If the value label already exists "... encode uses your encoding as far as it can and adds new mappings for anything not found in your value label." 

Also note that by default, -encode- assigns the same name to the -label- as to the variable name you provide, but -drop- only gets rid of the variable and leaves behind the homonymous, but now orphaned -label-. 


***
clear*

input str8 cntrystr
Germany
UK
USA
France
Spain
Portugal
end

encode cntrystr, gen(cntry)
la li cntry

drop cntry
//IMPORTANT:
la drop cntry
drop in 3/4
encode cntrystr, gen(cntry)
label list cntry
ta cntry, nol
***


HTH
Martin
-------- Original-Nachricht --------
> Datum: Tue, 29 Dec 2009 17:29:40 -0600
> Von: "Mike Kim" <[email protected]>
> An: [email protected]
> Betreff: st: Encode generates a wrong list

> Dear statalisters,
> 
> I have 60 countries in my dataset. "cntrystr" is string variable. To
> change 
> it into a numeric variable, I used the following code:
> 
> encode cntrystr, gen(cntry)
> label list cntry
> 
> It lists 60 countries. Then, I dropped 10 countries and wanted to generate
> a 
> new label list by the following code:
> 
> drop cntry
> encode cntrystr, gen(cntry)
> 
> However, Stata gives the same 60 countries. This is a problem because I
> want 
> to use "forvalues i=1/50 {... }" for my analysis and it is interrupted due
> to missing country numbers. How can I remove dropped countries in
> 'encode"?
> 
> Thank you in advance.
> Mike. 
> 
> *
> *   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/

-- 
GRATIS für alle GMX-Mitglieder: Die maxdome Movie-FLAT!
Jetzt freischalten unter http://portal.gmx.net/de/go/maxdome01
*
*   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–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index