Statalist


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

st: Changing labels in a string variable


From   "Tomasz Drabowicz" <tomasz.drabowicz@gmail.com>
To   statalist@hsphsun2.harvard.edu
Subject   st: Changing labels in a string variable
Date   Sat, 10 May 2008 14:02:52 +0200

Dear Statlist Members,

I have a beginner's problem. I am using Stata/IC 10.0 for Windows. In
my data set I have a string (str3) type variable COUNTRY (see below).
It does not have missing cases. In this variable I wanted to recode
numeric country codes (Country ID) into country names (e.g. '040' is
being replaced by 'Austria' etc.). I used two commands:

label define COUNTRY_label 040 "AUSTRIA" 056 "BELGIUM" 203 "CZECH
REPUBLIC" 208 "DENMARK" 246 "FINLAND" 250  "FRANCE" 276 "GERMANY" 300
"GREECE" 348 "HUNGARY" 352 "ICELAND" 372 "IRELAND" 380 "ITALY" 428
"LATVIA" 438  "LIECHTENSTEIN" 442 "LUXEMBOURG" 528 "NETHERLAND" 578
"NORWAY" 616 "POLAND" 620 "PORTUGAL" 703 "SLOVAKIA" 724  "SPAIN" 752
"SWEDEN" 756 "SWITZERLAND" 826 "UNITED KINGDOM"

label values COUNTRY COUNTRY_label

but STATa's response to the second command was:

may not label strings
r(181);

How can I recode labels in the string variable? Or where I can look
for information how to do that?

Thank you very much in advance for your help.

Best regards,

Tomasz Drabowicz
1st Year Research Student
Department of Political and Social Sciences
European University Institute
Via dei Roccettini 9
50014 San Domenico di Fiesole
Italy


tab COUNTRY

 Country ID |      Freq.     Percent        Cum.
------------+-----------------------------------
        040 |      4,597        3.44        3.44
        056 |      8,796        6.58       10.03
        203 |      6,320        4.73       14.76
        208 |      4,218        3.16       17.91
        246 |      5,796        4.34       22.25
        250 |      4,300        3.22       25.47
        276 |      4,660        3.49       28.96
        300 |      4,627        3.46       32.42
        348 |      4,765        3.57       35.99
        352 |      3,350        2.51       38.50
        372 |      3,880        2.90       41.40
        380 |     11,639        8.71       50.11
        428 |      4,627        3.46       53.58
        438 |        332        0.25       53.83
        442 |      3,923        2.94       56.76
        528 |      3,992        2.99       59.75
        578 |      4,064        3.04       62.79
        616 |      4,383        3.28       66.07
        620 |      4,608        3.45       69.52
        703 |      7,346        5.50       75.02
        724 |     10,791        8.08       83.10
        752 |      4,624        3.46       86.56
        756 |      8,420        6.30       92.86
        826 |      9,535        7.14      100.00
------------+-----------------------------------
      Total |    133,593      100.00
*
*   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–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index