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: creating a panel id variable from strings and decimals


From   Rebecca Pope <[email protected]>
To   [email protected]
Subject   Re: st: creating a panel id variable from strings and decimals
Date   Wed, 2 Jan 2013 08:39:11 -0600

encode city, generate(cityid) label(city)

alternately: egen cityid = group(city), label lname(city)

The advantage of -egen, group- is that it will work with either of
your cases. If you use -encode- for the latter case, you will need to
-tostring- first.

Rebecca


On Wed, Jan 2, 2013 at 8:29 AM, Bülent Köksal <[email protected]> wrote:
> Dear Stata Users,
>
> 1. How can I convert city names (strings) to city ids so that I can
> use it as a panel id variable?
>
> 2. What if there are numerical codes with decimals that correspond to
> each city rather than names. How can I achieve the same task above so
> that I can create a panel id variable?
>
> In the first case
>
> City
> AGB
> DFT
> EFH
> AGB
> EFH
> ...
>
> In the second case
>
> City
> 4.678
> 3.456
> 0.356
> 4.678
> 0.356
>
>
> Thanks in advance for any help.
>
> --
> Bülent Köksal
>
> *
> *   For searches and help try:
> *   http://www.stata.com/help.cgi?search
> *   http://www.stata.com/support/faqs/resources/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/faqs/resources/statalist-faq/
*   http://www.ats.ucla.edu/stat/stata/


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