Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Multencode: New Variables Question

    Hello,

    I've been trying to synchronize value labels from multiple surveys. I first decoded all numeric variable using the "decode" command, giving me a set of variables beginning with "s_".

    I am using "multencode" to re-create numeric variables that I had "decoded". The code below works to loop through all the variables that begin with "s_" (the string variables).

    Code:
    set more off
    foreach v of var s_*{
                multencode `v', gen(E`v')
            }
    I want to be able to modify the gen(E`v') to give me back the original variable names, without the "E_" prefixes.

    I would appreciate some help in fixing this code.

    thanks - Yy

  • #2
    The whole point of multencode (from SSC, as you are asked to explain) is to encode several variables at the same time and consistently. If you want to encode them one by one, you might as well use encode alone.

    Otherwise I guess the recipe you want is

    encode several variables to new variables

    drop those several variables

    use the old names now available to rename the new variables.

    Comment


    • #3
      ok, thanks Nick. I assuming I want to rename those list of variables all beginning with "E_", (by removing the prefix) is there a way to efficiently do this without typing the variables one by one (there are about 50 of them). I have already dropped the old variable names, so they are now available to use.

      Comment


      • #4
        Code:
        rename E_* *
        Best
        Daniel

        Comment


        • #5
          re: #3, see
          Code:
          help rename group
          esp #6 which shows how to drop prefixes

          Comment


          • #6
            thanks very much for your assistance - it all worked perfectly !

            Comment

            Working...
            X