Announcement

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

  • strpos function not found

    when I even I put this command I get this result

    . gen has_x= strpos (ICD , "X") >0
    strpos not found
    r(111);



    Code:
    * Example generated by -dataex-. To install: ssc install dataex
    clear
    input int(DOB Dateofstudy) str4 GENDER byte AGE str4 ICD
    -3538 19715 "Male" 63 "10X" 
    -5492 19711 "Male" 69 "13X" 
    -2395 19722 "Male" 60 "53N" 
    -4061 19712 "Male" 65 "33NX"
    -3676 19719 "Male" 64 "22G" 
    -3408 19719 "Male" 63 "27J" 
    -4884 19712 "Male" 67 "114s"
    -5500 19719 "Male" 69 "221" 
    -3542 19718 "Male" 63 "21x" 
    -3748 19722 "Male" 64 "225x"
    end
    format %tdnn/dd/CCYY DOB
    format %tdnn/dd/CCYY Dateofstudy
    any help or advice? thank you

  • #2
    Take out the spaces following the function name. Stata thinks you’re referring to a variable name strpos — which isn’t in your dataset.

    Comment


    • #3
      Thanks Nick

      Comment


      • #4
        Hello,

        I have a similar problem. Stata does not recognise command "strpos", so I tried to install it with ssc install strpos, but it can't find it.

        Code:
        . strpos(ER_1968,"_")
        command strpos is unrecognized
        r(199);
        And:


        Code:
        . ssc install strpos
        ssc install: "strpos" not found at SSC, type search strpos
        (To find all packages at SSC that start with s, type ssc descr
        > ibe s)
        r(601);

        Thanks a lot in advance,

        Francesco
        Last edited by Francesco Amodeo; 21 Jun 2019, 12:25.

        Comment


        • #5
          "strpos" is a function, not a command; however, you can still get help for it (it is part of official Stata) by
          Code:
          help strpos

          Comment


          • #6
            Originally posted by Rich Goldstein View Post
            "strpos" is a function, not a command; however, you can still get help for it (it is part of official Stata) by
            Code:
            help strpos

            Thanks.

            Of course I tried to do that, with no results. Here:
            Click image for larger version

Name:	del.jpg
Views:	1
Size:	79.9 KB
ID:	1505001


            It's very weird, isn't it?

            Could you tell me how to act now? It's Stata 15.0, I don't understand.


            Francesco

            Comment


            • #7
              Of course I tried to do that, with no results. Here:

              There is like a whole bunch of the results. Here:

              Click image for larger version

Name:	image_14943.jpg
Views:	1
Size:	122.4 KB
ID:	1505006

              Comment


              • #8
                What you want is:
                Code:
                gen some_variable = strpos(ER_1968,"_")

                Comment


                • #9
                  Originally posted by Sergiy Radyakin View Post


                  There is like a whole bunch of the results. Here:

                  [ATTACH=CONFIG]n1505006[/ATTACH]
                  Thanks Sergiy, the problem is that I clicked on those results, and no one of them seems to be installed or installable. This is why I was confused. No usual procedure for finding/installing commands.

                  Comment


                  • #10
                    It is already installed and you don't need to install anything else to use it.
                    Code:
                    sysuse auto, clear
                    count if strpos(make, "A")>0
                    count if strpos(make, "A")==0
                    count

                    Comment


                    • #11
                      Francesco Amodeo In #5 you already copied the answer to your question from #4. strpos() is a function, not a command. It is part of official Stata. There is no need to install anything (and no scope to do that any way).

                      Comment

                      Working...
                      X