Announcement

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

  • #16
    I abandoned the /// as I am using the command to check the syntax before saving it in the do file. So I need a syntax that works in both command and do file.
    I am using the syntax mentioned earlier:
    Code:
     #delimit ;
    lab define soft_h 1 "Colour"
    2 "Lemon"
    3 "Water"
    4 "Orange"
    5 "Tan"
    6 "Other1"
    7 "Other2"
    8 "Other3"
    9 "Don't Know"
    ;
    #delimit cr
    and it doesn't run from the do file.

    Comment


    • #17
      I can't see a problem with that code. You need to tell us more about what "doesn't run" means.

      Comment


      • #18
        For this syntax
        Code:
        recode soft (3=2) (8=3) (5=15) (2=5) (04 6 7=8) ,gen (soft_h) 
         #delimit ; lab define soft_h 1 "Colour" 2 "Lemon" 3 "Water" 4 "Orange" 5 "Tan" 6 "Other1" 7 "Other2" 8 "Other3" 9 "Don't Know" ; #delimit cr
        I get:

        Code:
        >
        > recode soft 4=3 3=4 5=6, gen (soft_h)
        > # delimit ;
        invalid 'gen' 
        r(198);
        But this is happening interchangeably, that is, sometimes I run the do file and it gives me no errors, while others it shows me that error message

        Comment


        • #19
          I think I understood what was happening. I had a ; missing some rows before. This took loads of time to figure out. So the syntax worked when I run that bit independently, but it stopped when I was running the entire do file at once.
          As I mentioned this is new to me, so I am sorry for the lack of clarity sometimes. I will do better next time.
          Thanks for all the help.

          Comment


          • #20
            I suggest you close up those spaces. gen(soft_h) not gen (soft_h)

            Stata parses on spaces. The syntax for recode includes an option generate() that you can abbreviate down to g() but there is no option of the same name without an argument.

            Also, I doubt that Stata is as capricious as you're implying. I'll guess that sometimes you don't include space and sometimes you do.

            Comment

            Working...
            X