Announcement

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

  • recoding dummy variables

    How do I recode my dummy variables please? I have 3 categories 0,1,2 and I mistakenly coded 1 for 2 so I need to switch it around. 0 is fine but 2 should be 1 and 1 should be 2. I have labels already defined so how would I redefine the labels accordingly as well? Thank you.

  • #2
    Code:
    recode list_of_variables_to_be_recoded (2 = 1) (1 = 2)
    As for the labeling, just use the -label define- command in the usual way to specify the correct labels for corrected values 1 and 2, and then add the -modify- option.

    Comment


    • #3
      Thank you so much Mr Schechter. I have another question if you don't mind. I am trying to group 2 graphs (margins plot) to compare them but there is error msg with ylabel on both of my commands to title the graph as well as to combine. Am I doing something wrong? Can you help clarify please?Below are my commands.

      margins, at(finscore==(0 1 2 3 4 5))
      marginsplot, recast(scatter) scheme(lean2), ylabel( , angle(horizonatal)) xtitle(finscore) name(finscore_scale,replace)
      margins, at(subfin==(1 2 3 4 5 6 7))
      marginsplot, recast(scatter) scheme(lean2), ylabel( , angle(horizonatal)) xtitle(subfin) name(subfin_scale,replace)
      graph combine finscore_scale subfin_scale, name(combined, replace)

      Thank you for your kind consideration.
      ​​​​​​​Yours truly,
      Lena

      Comment


      • #4
        It is easy to (mistakenly) think of the Forum threads as dialogs between a questioner and a responder. But they are more than that: other people browse the Forum and select what to read based on the thread title. Still others search the Forum for answers to questions they suspect others have already dealt with here. So it is important to keep threads on topic. The question raised in #3 has nothing at all to do with recoding dummy variables. So others will either be misled into reading about this -graph- problem, or not be able to find this graph question. In the future, when changing topic, please start a new thread.

        That said, the answer to this question is quick. There should not be a comma between scheme(lean2) and ylabel(). In any Stata command, a single comma separates the main part of the command from all of the options. But options are not themselves separated by commas, just by whitespace. The only commas that should appear inside the options part of the command are used to separate suboptions (like the replace within the name() option) from the option they modify.

        Comment

        Working...
        X