Announcement

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

  • r(198)

    Hi!

    I am trying to label the variable depart_nacio, which was a string variable, but I applied destring to it.
    When I run the forllowing code, it says at the end " invalid syntax" r(198)


    label var depart_nacio "Departamento de Nacimiento"
    label depart_naciol 05 "Antioquia" /*
    */ 8 "Atlántico" /*
    */ 11 "Bogotá D.C" /*
    */ 13 "Bolivar" /*
    */ 15 "Boyacá" /*
    */ 17 "Caldas" /*
    */ 18 "Caquetá" /*
    */ 19 "Cauca" /*
    */ 20 "Cesar" /*
    */ 23 "Córdoba" /*
    */ 25 "Cundinamarca"/*
    */ 27 "Choco" /*
    */ 41 "Huila" /*
    */ 44 "La Guajira" /*
    */ 47 "Magdalena" /*
    */ 50 "Meta" /*
    */ 52 "Nariño" /*
    */ 54 "Norte de Santander" /*
    */ 63 "Quindio" /*
    */ 66 "Risaralda" /*
    */ 68 "Santander" /*
    */ 70 "Sucre" /*
    */ 73 "Tolima" /*
    */ 76 "Valle del Cauca" /*
    */ 81 "Arauca" /*
    */ 85 "Casanare" /*
    */ 86 "Putumayo" /*
    */ 88 "San Andres" /*
    */ 91 "Amazonas" /*
    */ 94 "Guainia" /*
    */ 95 "Guaviare" /*
    */ 97 "Vaupes" /*
    */ 99 "Vichada"
    label value depart_nacio depart_naciol


    what is the issue?

  • #2
    Seems you've used a lot of "block quote", which is */ + /*. Maybe confusing with line break "///". Another reason could be wrong command, a word "define" is missing. Try this:

    Code:
    label var depart_nacio "Departamento de Nacimiento"
    label define depart_naciol 05 "Antioquia" ///
     8 "Atlántico" ///
     11 "Bogotá D.C" ///
     13 "Bolivar" ///
     15 "Boyacá" ///
     17 "Caldas" ///
     18 "Caquetá" ///
     19 "Cauca" ///
     20 "Cesar" ///
     23 "Córdoba" ///
     25 "Cundinamarca"///
     27 "Choco" ///
     41 "Huila" ///
     44 "La Guajira" ///
     47 "Magdalena" ///
     50 "Meta" ///
     52 "Nariño" ///
     54 "Norte de Santander" ///
     63 "Quindio" ///
     66 "Risaralda" ///
     68 "Santander" ///
     70 "Sucre" ///
     73 "Tolima" ///
     76 "Valle del Cauca" ///
     81 "Arauca" ///
     85 "Casanare" ///
     86 "Putumayo" ///
     88 "San Andres" ///
     91 "Amazonas" ///
     94 "Guainia" ///
     95 "Guaviare" ///
     97 "Vaupes" ///
     99 "Vichada"
    label values depart_nacio depart_naciol

    Comment


    • #3
      I agree, the second line is missing the define keyword. But here's the thing, contrary to my expectations, it appears to be legal to use a block comment to comment out the return whitespace character. I tested this because I (incorrectly) said that this was not valid syntax in one of Silvana's recent posts.

      Code:
      clear all
      set obs 5
      
      egen i = fill(/*
      */1 2 3 4 5)
      list
      Code:
      . list
      
           +---+
           | i |
           |---|
        1. | 1 |
        2. | 2 |
        3. | 3 |
        4. | 4 |
        5. | 5 |
           +---+
      This might be obvious to some here, but I definitely was not expecting that this would work.
      Last edited by Daniel Schaefer; 10 Sep 2023, 15:25.

      Comment


      • #4
        This might be obvious to some here, but I definitely was not expecting that this would work.
        I've been using Stata long enough that I can remember back to a time when /* */ was the only way, other than -delimit ;- to spread a command over more than one line. I largely abandoned using it the minute Stata introduced ///, but the memory of it lingers. I'm sure it has been preserved to avoid breaking legacy code written in Juassic times.

        Added: To be clear, I have not abandoned the use of /* */ entirely. I still use it to comment out large blocks of code. But I no longer use it to break a command over multiple lines.
        Last edited by Clyde Schechter; 10 Sep 2023, 16:59.

        Comment


        • #5
          Oh, I think I see the trick now! On each row its */ ... /* and NOT /* ... */. So it's the line breaks that got commented out.

          Thank you Clyde and Daniel.

          Comment


          • #6
            Thnak you guys!!! Solved issue

            Comment

            Working...
            X