Announcement

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

  • unrecognized string functions

    Hi
    My question is so simple but weird.
    I'm using STATA 14 MP and string functions does not work
    For example, I wrote : lower("THIS") , then STATA showed the message "command lower is unrecognized".
    Other commands like : length("ab"), strlen("ab") strpos("this","is") also does not recognized.
    I could not any others' questions who have similar problem.
    Could you help my embarrassing problem?

  • #2
    I think that you need to have the function's return value consumed in some manner, ether as part of an expression or as the argument of, say, the display command. Try
    Code:
    display strlower("THIS")
    You can type a function on Mata's command line interactively, but you cannot just type a function with its argument on Stata's command line. You need to type commands and their arguments on Stata's command line.

    Comment


    • #3
      To echo Joseph's helpful answer:

      In essence Stata expects that each command ... is a command. That is, you type commands in the Command window or issue them in sequence in a program or a do-file.

      Functions are not commands.

      Whatever terminology you may be used to from other experience can't be assumed to apply to Stata here. In Stata, commands and functions are entirely different entities. Commands can be and often are issued without naming any function at all, but the opposite isn't true.

      So, Stata plays dumb and says "That's not a command" when you just type a function. You need a command first, and in your example the command you need is display.

      Mata is different: in fact, it doesn't have commands, and it's fine to type a function call.


      N.B. Stata not STATA: do see http://www.statalist.org/forums/help#spelling

      Comment

      Working...
      X