Announcement

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

  • line breaks in command -global-

    Dear all,How can I break line in the command -global-.I use "///" ,but I get error.My codes in dofile is
    Code:
    global m "mvalue kstock L.mvalue  c.mvalue#c.mvalue c.kstock#c.kstock c.mvalue#c.kstock   ///
    L.kstock c.L.kstock#c.L.mvalue c.L.mvalue#c.L.mvalue c.L.kstock#c.L.kstock i.year"  
    
    global m "mvalue kstock L.mvalue  c.mvalue#c.mvalue c.kstock#c.kstock c.mvalue#c.kstock   ///
    invalid syntax
    r(198);
    Anyone can give me some suggestions?Thanks a lot.

    Best
    Raymond
    Best regards.

    Raymond Zhang
    Stata 17.0,MP

  • #2
    A few solutions here:

    Code:
    global m "mvalue kstock L.mvalue  c.mvalue#c.mvalue c.kstock#c.kstock c.mvalue#c.kstock " ///
    "L.kstock c.L.kstock#c.L.mvalue c.L.mvalue#c.L.mvalue c.L.kstock#c.L.kstock i.year"
    Or you could use #delimit:

    Code:
    #delimit ;
    global m "mvalue kstock L.mvalue  c.mvalue#c.mvalue c.kstock#c.kstock c.mvalue#c.kstock 
    L.kstock c.L.kstock#c.L.mvalue c.L.mvalue#c.L.mvalue c.L.kstock#c.L.kstock i.year";
    #delimit cr
    Or:

    Code:
    global m "mvalue kstock L.mvalue  c.mvalue#c.mvalue c.kstock#c.kstock c.mvalue#c.kstock " /*
    */"L.kstock c.L.kstock#c.L.mvalue c.L.mvalue#c.L.mvalue c.L.kstock#c.L.kstock i.year"

    Comment


    • #3
      @Ali AtiaThank you for your help.It solves my problem.
      Best regards.

      Raymond Zhang
      Stata 17.0,MP

      Comment


      • #4
        @Ali Atia I use your method, but there is still problem.
        Code:
        global m "mvalue kstock L.mvalue  c.mvalue#c.mvalue c.kstock#c.kstock"   ///
         "c.mvalue#c.kstock L.kstock cL.kstock#cL.mvalue cL.mvalue#cL.mvalue cL.kstock#cL.kstock i.year"  
        
         xtreg invest $m,fe
        "     invalid name
        r(198);
        Best regards.

        Raymond Zhang
        Stata 17.0,MP

        Comment


        • #5
          Try the delimit code from #2.

          Comment


          • #6
            Note that the problem in post #1 was caused by trying to continue a string surrounded by quotation marks over multiple lines.

            However, a macro like this, containing a list of elements, does not necessarily require surrounding quotation marks.
            Code:
            . #delimit ;
            delimiter now ;
            . global m1 "mvalue kstock L.mvalue  c.mvalue#c.mvalue c.kstock#c.kstock c.mvalue#c.kstock
            > L.kstock c.L.kstock#c.L.mvalue c.L.mvalue#c.L.mvalue c.L.kstock#c.L.kstock i.year";
            
            . #delimit cr
            delimiter now cr
            .
            . global m2 mvalue kstock L.mvalue  c.mvalue#c.mvalue c.kstock#c.kstock c.mvalue#c.kstock ///
            > L.kstock c.L.kstock#c.L.mvalue c.L.mvalue#c.L.mvalue c.L.kstock#c.L.kstock i.year
            
            . macro list m1 m2
            m1:             mvalue kstock L.mvalue c.mvalue#c.mvalue c.kstock#c.kstock c.mvalue#c.kstock
                            L.kstock c.L.kstock#c.L.mvalue c.L.mvalue#c.L.mvalue c.L.kstock#c.L.kstock i.year
            m2:             mvalue kstock L.mvalue c.mvalue#c.mvalue c.kstock#c.kstock c.mvalue#c.kstock
                            L.kstock c.L.kstock#c.L.mvalue c.L.mvalue#c.L.mvalue c.L.kstock#c.L.kstock i.year

            Comment

            Working...
            X