Statalist


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

st: How to attach a string to a numeric variable as its value lable


From   "Jia Xiangping" <[email protected]>
To   statalist <[email protected]>
Subject   st: How to attach a string to a numeric variable as its value lable
Date   Tue, 25 Mar 2008 16:32:12 -0400

Dear all,

There are two variables, one string and one numeric. The meaning of x
is supposed to be attached to y as its value label.

x                 y
RAKAI         21 	
RAKAI         21 	
RAKAI         21 	
MASAKA     22 	
MASAKA     22 	
MASAKA     22 	
MASAKA     22 	
MBALE         23 	
MBALE         23 	
MBALE         23 	
SIRONKO      24 	
SIRONKO      24 	
TORORO       25 	
TORORO       25 	
BUSIA           26 	


The simple way I did was:
. encode x, gen(newx)
. replace newx=y
. list newx y

Then it is found some are not replaced. I must read a solution
somewhere, but I can not recall it. Could someone give a quick
solution? Thanks.

                  newx              x
 65. |      TORORO        IGANGA |
 66. |      WAKISO        MAYUGE |
 67. |      WAKISO        MAYUGE |
 68. |      WAKISO        MAYUGE |
 69. |      WAKISO        MAYUGE |
 70. |      WAKISO        MAYUGE |
 71. |      WAKISO        MAYUGE |
 72. |          30         JINJA |
 73. |          30         JINJA |
 74. |          30         JINJA |
 75. |          31        KAMULI |
 76. |          31        KAMULI |


ps. Stata 10. Windows XP.



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