Statalist


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

Re: st: combining two variables


From   Johannes Schoder <[email protected]>
To   [email protected]
Subject   Re: st: combining two variables
Date   Sat, 12 Sep 2009 15:40:41 -0400

Cool thanks a lot Joseph!!

Joseph McDonnell schrieb:
Johannes

if the second variable is a string, you can concatenate it with state

. gen county=state+number

If it's numeric, use the string function with a format

. gen county=state+string(number,"%02.0f")

If you want to attach the names to the county code, you'd need to
download a list from elsewhere and merge into your data.

HTH

Joseph

On Sat, Sep 12, 2009 at 9:54 AM, Johannes Schoder
<[email protected]> wrote:
Dear Statalist users:

I would like to combine two variables in one:

The first variable represents the state: e.g. CA (California) or AZ
(Arizona).
The second variable represents the countiy and includes numbers: 01,...

The combination of both variables finally states from which county the
individual is from, e.g. CA 01 is county Alameda, AZ 01 is county Apache,
etc.
Does anyone know a trick how to combine both variables so that it identifies
uniquely the county where the person is from?
Thanks a lot!!
Johannes

*
*   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/

*
*   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