Statalist


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

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


From   "Chen, Xiao" <[email protected]>
To   <[email protected]>
Subject   st: RE: How to attach a string to a numeric variable as its value lable
Date   Tue, 25 Mar 2008 17:51:24 -0700

Another way of doing it might be via Nick Cox's labutil suite. We have
an example page on how to do it using his command labmask:

http://www.ats.ucla.edu/stat/Stata/faq/labmask.htm

Basically it should be something like:

labmask y, values(x)

You need to "findit labutil" in Stata to download the entire suite of
very useful tools.

_______________________________
Xiao Chen
Statistical Consulting Group
UCLA Academic Technology Services
http://www.ats.ucla.edu/stat/
 
UCLA researchers are welcome and invited to walk-in consulting. 
4919 Math Sciences (see lab #5 at
http://www.computerlabs.ucla.edu/Map.asp)
 
Walk-in Consulting Hours: Mon, Tue, Thur 10-12 & 2-4, Wed 2-4, Fri.
10-12 
see http://www.ats.ucla.edu/stat/schedule/ for details 

 

 
 

-----Original Message-----
From: [email protected]
[mailto:[email protected]] On Behalf Of Jia Xiangping
Sent: Tuesday, March 25, 2008 1:32 PM
To: statalist
Subject: st: How to attach a string to a numeric variable as its value
lable

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/

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