Announcement

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

  • Invalid syntax with "define label order"

    Hello,

    I am trying to change the order in which the values of some variables are presented but keep getting syntax errors. I am using Stata 13.0

    This first command gets accepted: label define order 1 VMBO 2 HAVO 3 VWO 4 MBO 5 HBO 6 WO 7 PhD

    But i keep getting errors for the following command:
    label define order2 1 younger than 18 2 18-24 3 25-34 4 35-44 5 45-54 6 55-64 7 older than 64

    The error i get is: invalid syntax. I already tried to alter the categories using <18 and >64, but that does not seem to solve the problem.

    The following commands also get rejected:
    * label define order3 1 Single 2 In a relationship but living apart 3 Living together 4 Married 5 Divorced
    * label define order4 1 Student 2 Employed 3 Not employed but looking for a job 4 Not employed and not looking for a job 5 Unable to work 6 Retired

    Can you help me with solving this problem?




  • #2
    You need " " around strings with embedded spaces.

    Code:
    label define order2 1 "younger than 18" 2 "18-24" 3 "25-34" 4 "35-44" 5 "45-54" 6 "55-64" 7 "older than 64"
    and they do no harm even when they aren't essential. But note that (re)defining labels won't itself change the order of anything, so you may need to explain your larger problem.

    Comment


    • #3
      Well, i want to change the order of categories when i tabulate the variable. Stata sorts them automatically in alphabetical order.
      Your advice solved the problem for me, thank you very much!!

      Comment

      Working...
      X