Announcement

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

  • command "strupper" is unrecognised

    Hi all, I don't know why it happens when I wrote:
    strupper ("hallo")
    the error: command strupper is unrecognised r(199).
    It also occurs with other commands such as ustrright, udstrlen.
    I'm using STATA 16.1
    Can anyone advise me what I should do to solve such a weird problem?

  • #2
    Code:
    display strupper("hello")

    Comment


    • #3
      To expand on Øyvind Snilsberg's helpful answer:

      strupper() is a function, not a command. In Stata, functions and commands are distinct. You can use functions in many commands, but they can only be used within commands.

      What you're expecting often makes sense in other software wherever a function call by itself results in display of the result, but in Stata you need a display command to do that.

      What you tried works in Mata

      Code:
      . mata: strupper("hello")
        HELLO
      The other "commands" you mention are also really functions, and it's the same story with them.

      Comment


      • #4
        Thank Øyvind Snilsberg and Nick Cox for the answer and further explanation!
        I would like to make values of the var co02_01 uppercase and to get the last 4 digits of var co02_02, and here are my codes:
        Code:
        gen co02_01a = strupper (co02_01), after (co02_01)
        gen co02_02a = ustrright (co02_02,4), after (co02_02)

        and the data:
        Code:
        clear
        input int ref str2 co02_01 str5 co02_02
         32 "GA" "1305"
         32 "GA" "1305"
        92 "GA" "1305"
        96 "GW" "'0517"
        100 "Gw" "'0517"
        100 "Gw" "'0517"
        100 "Gw" "'0517"
        104 "UF" "'0541"
        104 "UF" "'0541"
        104 "Uf" "'0541"
        104 "UF" "'0541"
        117 "em" "'0737"
        117 "EM" "'0737"
        end


        The error always showed: “strupper not found”
        In addition, I wrote the same codes in another dataset, it worked perfectly. But this time doesn’t.
        I would be very grateful if you can help me out with this matter. Thanks a lot!

        Comment


        • #5
          So that explains the question, although now I look again the present problem is also visible in #1.

          Take out the space between the function name and its argument.


          Code:
           gen co02_01a = strupper(co02_01), after (co02_01) 
          Last edited by Nick Cox; 21 Dec 2021, 08:50.

          Comment


          • #6
            A Thousand thanks to Nick Cox !!! It works. Never ever forget such the mistake.

            Comment

            Working...
            X