Statalist The Stata Listserver


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

st: A question about recoding with wildcard


From   "Jia Xiangping" <jiajoseph@googlemail.com>
To   statalist@hsphsun2.harvard.edu
Subject   st: A question about recoding with wildcard
Date   Mon, 18 Sep 2006 23:36:35 +0800

Dear List friends,

I come across one problem. Hope you can help me out.

There are one set of variables n1 n6 n11..., with step 5.  The content
of these variables are codes of different crops, with 1$$ and 1 coded
as wheat (1$$ are the sub-categories of wheat). Now I have to recode
all the 1$$ to 1 , because it is inconsistent with the coding system
of other tables, which do NOT use the sub-categories. Call you
attention: crops which are coded as 1$ are totally different crops and
I should no recode them.

In what follows, I present the way I did and the error information.

version 8.2
forvalue  i=1(5)41 {
recode n233`i' (1$$=1 wheat)  ///
(2$$=2 maize) (missing=.), gen(sw)
}
unknown el 1$$ in rule
r(198);

The sampling data:
list n2331 n2336 n23311, nolabel
57. |   165     270       17 |
58. |   165      17        . |
59. |   165      17       30 |
60. |     1       2       17 |
    |------------------------|
61. |   165      17        . |
62. |   195       .        . |
63. |   170     267        . |
64. |   170     267       19 |
65. |   170     267       19 |
    |------------------------|
66. |   165     235       17 |
67. |   170     267        . |
68. |     1       2       19 |
69. |     1       2       19 |
70. |     1       2       19 |
    |------------------------|
71. |     1       2       19 |
72. |     1      19       12 |
73. |    12      19        2 |
74. |     1       2       19 |
75. |     1      19       12 |
    |------------------------|
76. |     1       2       12 |
77. |     1       2       19 |
78. |     1       2       12 |
79. |     1       2       12 |
80. |     1       2       19 |

list n2331 n2336 n23311
57. |  yumai18   linao_no     peanut |
58. |  yumai18     peanut          . |
59. |  yumai18     peanut   water_me |
60. | winter_w   summer_m     peanut |
    |--------------------------------|
61. |  yumai18     peanut          . |
62. | zhoumai1          .          . |
63. |  yumai34   zhengdan          . |
64. |  yumai34   zhengdan     cotton |
65. |  yumai34   zhengdan     cotton |
    |--------------------------------|
66. |  yumai18   nongda10     peanut |
67. |  yumai34   zhengdan          . |
68. | winter_w   summer_m     cotton |
69. | winter_w   summer_m     cotton |
70. | winter_w   summer_m     cotton |
    |--------------------------------|
71. | winter_w   summer_m     cotton |
72. | winter_w     cotton     garlic |
73. |   garlic     cotton   summer_m |
74. | winter_w   summer_m     cotton |
75. | winter_w     cotton     garlic |
    |--------------------------------|
76. | winter_w   summer_m     garlic |
77. | winter_w   summer_m     cotton |
78. | winter_w   summer_m     garlic |


--
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–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index