Announcement

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

  • global macros

    Dear all,

    Thank you for helping me. I have defined a global macro, but stata says there is sth wrong with it, when I use it. The following is my syntax:

    sysuse nlsw88.dta, clear
    global xx "hours ttl_exp married union"

    reg wage $xx
    est store homo

    But stata says the following:

    reg wage $xx
    “hours invalid name
    r(198);


    end of do-file

    r(198);

    why it is a invalid name? I have defined and used it correctly.

    Best,

    Eddie

  • #2
    Strange ... seems to work here

    Code:
    . sysuse nlsw88.dta, clear
    (NLSW, 1988 extract)
    
    . 
    . global xx "hours ttl_exp married union"
    
    . 
    . reg wage $xx
    
          Source |       SS           df       MS      Number of obs   =     1,877
    -------------+----------------------------------   F(4, 1872)      =     84.34
           Model |  4978.16489         4  1244.54122   Prob > F        =    0.0000
        Residual |  27624.8151     1,872  14.7568457   R-squared       =    0.1527
    -------------+----------------------------------   Adj R-squared   =    0.1509
           Total |    32602.98     1,876  17.3789872   Root MSE        =    3.8415
    
    ------------------------------------------------------------------------------
            wage |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
    -------------+----------------------------------------------------------------
           hours |   .0181568   .0092679     1.96   0.050    -.0000198    .0363334
         ttl_exp |   .3136889   .0198635    15.79   0.000      .274732    .3526458
         married |  -.1012254   .1888015    -0.54   0.592     -.471509    .2690583
           union |   1.254488   .2067192     6.07   0.000     .8490642    1.659913
           _cons |   2.621753   .4285486     6.12   0.000      1.78127    3.462236
    ------------------------------------------------------------------------------

    Comment


    • #3
      Mike's answer prompted me to look closely at your error message. I can reproduce your problem with a change to the code you displayed.
      Code:
      . sysuse nlsw88.dta, clear
      (NLSW, 1988 extract)
      
      . global xx hours ttl_exp married union
      
      . reg wage $xx
      “hours invalid name
      r(198);
      Note that the quotation marks (highlighted in red) are "smart quotes" rather than the standard textual quotation marks that you showed in the code you presented in post #1 and that Mike used in post #2. This suggests to me that your code had actually been copied from Word or some other text editor that uses "smart quotes" and pasted into Stata when it was run.

      Please review the Statalist FAQ linked to from the top of the page, as well as from the Advice on Posting link on the page you used to create your post. Note especially sections 9-12 on how to best pose your question.

      Section 12.1 is particularly pertinent

      12.1 What to say about your commands and your problem

      Say exactly what you typed and exactly what Stata typed (or did) in response. N.B. exactly!
      as is Section 12.3 on the use of code delimiters [CODE] and [/CODE] to present code and output copied and pasted from the Do-file Editor or the Results window.

      The more you help others understand your problem, the more likely others are to be able to help you solve your problem.

      Comment


      • #4
        And (even more convenient) it's als working without any quotes

        Code:
        . sysuse nlsw88.dta, clear
        (NLSW, 1988 extract)
        
        . global xx hours ttl_exp married union
        
        . reg wage $xx
        
              Source |       SS           df       MS      Number of obs   =     1,877
        -------------+----------------------------------   F(4, 1872)      =     84.34
               Model |  4978.16489         4  1244.54122   Prob > F        =    0.0000
            Residual |  27624.8151     1,872  14.7568457   R-squared       =    0.1527
        -------------+----------------------------------   Adj R-squared   =    0.1509
               Total |    32602.98     1,876  17.3789872   Root MSE        =    3.8415
        
        ------------------------------------------------------------------------------
                wage |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
        -------------+----------------------------------------------------------------
               hours |   .0181568   .0092679     1.96   0.050    -.0000198    .0363334
             ttl_exp |   .3136889   .0198635    15.79   0.000      .274732    .3526458
             married |  -.1012254   .1888015    -0.54   0.592     -.471509    .2690583
               union |   1.254488   .2067192     6.07   0.000     .8490642    1.659913
               _cons |   2.621753   .4285486     6.12   0.000      1.78127    3.462236
        ------------------------------------------------------------------------------

        Comment

        Working...
        X