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: How can I create a new variable based on labels for another variable?


From   "Ada Ma" <[email protected]>
To   [email protected]
Subject   Re: st: How can I create a new variable based on labels for another variable?
Date   Mon, 11 Apr 2011 23:02:05 +0000

Another alternative is to refer to the label's name as well as the string's contents. Then you need not -decode- at all.

E.g. asssume the label's name is countrylabel,


Gen UKdum=1 if country=="United Kingdom":countrylabel

More details can be found in Stata Tip 14 in the Stata Journal. 




Sent using BlackBerry®

-----Original Message-----
From: Joerg Luedicke <[email protected]>
Sender: [email protected]
Date: Mon, 11 Apr 2011 15:12:55 
To: <[email protected]>
Reply-To: [email protected]: Re: st: How can I create a new variable based on labels for another variable?

On Mon, Apr 11, 2011 at 3:01 PM, Qursum Qasim <[email protected]> wrote:
> Hi all,
>
> I've got a dataset where the countries have been given numeric codes
> and the names of the countries are given as labels associated with
> each numeric code. I am trying to create a new string variable that
> will contain the labels (country names instead of the numeric codes).
> Any ideas how I can do that?
> Thanks!
>
> Regards,
> Qursum Qasim
> *
> *   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/
>

-decode- should be appropriate for that job.

J.

*
*   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–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index