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

Re: st: combining two variables

From   "Michael I. Lichter" <[email protected]>
To   [email protected]
Subject   Re: st: combining two variables
Date   Fri, 11 Sep 2009 23:32:55 -0400

If you're using FIPS county codes, they're 2-digit state + 3-digit county.

gen int fipscnty = (1000 * state) + county

I'm assuming you want this numeric. You can also create a string code
like this:

gen str5 fipscnty = string(state, "%02.0f") + string(county, "%03.0f")

The "%0#.#f" format creates leading 0s as needed.


Johannes Schoder 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!!

*   For searches and help try:

Michael I. Lichter, Ph.D. <[email protected]>
Research Assistant Professor & NRSA Fellow
UB Department of Family Medicine / Primary Care Research Institute
UB Clinical Center, 462 Grider Street, Buffalo, NY 14215
Office: CC 126 / Phone: 716-898-4751 / FAX: 716-898-3536
*   For searches and help try:

© Copyright 1996–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index