Announcement

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

  • Documentation for =exp option in syntax

    Hi Statalist,

    I am trying to write a command with the following syntax: varname =/ exp. I'm getting the error below when exp is a string. It seems that the syntax check tests if the input is either a number of a numeric variable. However, there's nothing in the documentation stating that exp should be numeric, and the most immediate example of a command with this syntax, gen, obviously accepts strings and string variables as input.

    Here is one example:

    This command
    Code:
    capture program drop testexp
    program testexp
    
        syntax anything =/ exp
        
        noi di `" `exp' "'
            
    end
    Gives me these results:
    . * Using a number

    . testexp exp = 1
    1

    . * Using a numeric variable

    . testexp exp = key
    key

    . testexp exp = ln(key)
    ln(key)

    . * Using a variable that does not exist

    . testexp exp = foo
    foo not found
    r(111);

    . * Using a string

    . testexp exp = "foo"
    type mismatch
    r(109);
    Has anyone had this issue before or knows where I can find documentation on this option?

    Thanks a lot!
    Luiza

  • #2
    I did never run into this myself. I dare call this a bug in syntax.

    Best
    Daniel

    Comment

    Working...
    X