Statalist The Stata Listserver


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

Re: st: Creating a new numerical variable without mathematicaloperations


From   "Frederick J. Boehmke" <[email protected]>
To   [email protected]
Subject   Re: st: Creating a new numerical variable without mathematicaloperations
Date   Sat, 21 Oct 2006 10:15:36 -0400 (EDT)

If I understand the range of the two variables properly, perhaps:

gen newcity = 10000*province + city

will work?

On Sat, 21 Oct 2006, Ramani Gunatilaka wrote:

Date: Sat, 21 Oct 2006 14:47:09 +0100
From: Ramani Gunatilaka <[email protected]>
Reply-To: [email protected]
To: [email protected]
Subject: st: Creating a new numerical variable without mathematical operations

Dear all,
I have two numerical variables, province and city: province has two
digits, city has at least 4.
eg. province= 11, city=  6227
I want to create a new numerical variable called 'newcity' which will
combine province and city like this:
116227
This is because I have to combine this data set with another, and the
unique identifying variable in the second data set has been
constructed in this way.
Can someone please tell me what command I may use?
Thanks so much,
Ramani
*
*   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/



                                                         - Fred

 Note updated contact info (from August 01, 2005 to August 01, 2007):

                               Frederick J. Boehmke
                     Associate Professor of Political Science
                           University of Iowa (on leave)
                                [email protected]
          _-------------------------------------------------------------_
         <        Robert Wood Johnson Foundation Research Fellow         >
         <  University of Michigan               Office: M2232 (SPH II)  >
         <  School of Public Health              Phone:  734 764 2089    >
         <  Health Management and Policy         Fax:    734 936 9813    >
         <  109 Observatory, Room M2232          [email protected]       >
         <_ Ann Arbor, MI  48109-2029                                   _>
           -------------------------------------------------------------
                          http://myweb.uiowa.edu/fboehmke
*
*   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