Announcement

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

  • Create local macro already with double quotataion marks

    Dear Statalist

    I would like to create a local macro for an if-condition that already includes double quotation marks (" "). And I would like to ask how I may accomplish this without confusing Stata because of the multiple " " marks. To illustrate what I mean:

    Code:
    sysuse auto, clear
    regress price mpg if foreign == "Domestic":origin
    In this context, please imagine the if-condition
    Code:
     if foreign == "Domestic":origin
    to be much longer & that I would like to include the actual labels instead of, e.g. foreign == 1, to improve readability for my coauthors.

    It would be ideal if I can do something like
    Code:
     local ifcond = "if foreign == "Domestic":origin" 
    regress price mpg `ifcond'
    But, as it stands, the multiple " " marks are causing confusion.

    Thanks,
    Junran


  • #2
    There is no issue with this:

    Code:
    local ifcond "if foreign == "Domestic":origin"
    regress price mpg `ifcond'

    Comment


    • #3
      Oh I see. Thanks very much Andrew. I had been under the mistaken impression that
      Code:
       
       local ifcond = "if foreign == "Domestic":origin"
      if equivalent to
      Code:
        
       local ifcond "if foreign == "Domestic":origin"
      The former led to a syntax error but the latter, as you point out, works just fine.

      Comment

      Working...
      X