Statalist The Stata Listserver


[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: generating a new variable without maths


From   Kit Baum <[email protected]>
To   [email protected]
Subject   st: generating a new variable without maths
Date   Sat, 21 Oct 2006 16:35:17 -0400

If you're not using maths, you must be using strings!

     +-----------------+
     | province   city |
     |-----------------|
  1. |       11    321 |
  2. |       22   4321 |
  3. |       33     21 |
     +-----------------+

. gen idcode=real(string(province)+string(city))

. l

     +--------------------------+
     | province   city   idcode |
     |--------------------------|
  1. |       11    321    11321 |
  2. |       22   4321   224321 |
  3. |       33     21     3321 |
     +--------------------------+



Kit Baum, Boston College Economics
http://ideas.repec.org/e/pba1.html
An Introduction to Modern Econometrics Using Stata:
http://www.stata-press.com/books/imeus.html


*
*   For searches and help try:
*   http://www.stata.com/support/faqs/res/findit.html
*   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