Announcement

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

  • How to strltrim the data in a variable for stata15

    In command, I use strltrim(the varibale name), but then it showed command strltrim is unrecognized. I have string all the variables.

  • #2
    That error appears because -strltrim- is not a command, it is a function. You can enter something like the following

    Code:
    generate newvar = strltrim(oldvar)
    where the -generate- command uses the strltrim function.

    Comment


    • #3
      Originally posted by Hemanshu Kumar View Post
      That error appears because -strltrim- is not a command, it is a function. You can enter something like the following

      Code:
      generate newvar = strltrim(oldvar)
      where the -generate- command uses the strltrim function.
      I tried but still not working, the data in excel are in a new line, so the first line is empty, then the second line is the input. How should I delete the empty row?

      Comment


      • #4
        I would opt to use -ustrltrim()- instead of its non-Unicode counterpart because the Unicode version handles Unicode whitespace and blanks, including new line and linefeed characters from the ASCII subset.

        Comment


        • #5
          Originally posted by vicky chann View Post

          I tried but still not working, the data in excel are in a new line, so the first line is empty, then the second line is the input. How should I delete the empty row?
          Please use -dataex- to post a sample of your data so that it is easier for others to understand your issue, replicate it, and solve the problem.

          Comment


          • #6
            Originally posted by Leonardo Guizzetti View Post
            I would opt to use -ustrltrim()- instead of its non-Unicode counterpart because the Unicode version handles Unicode whitespace and blanks, including new line and linefeed characters from the ASCII subset.
            this solved the problem! thanks!

            Comment


            • #7
              Originally posted by Hemanshu Kumar View Post

              Please use -dataex- to post a sample of your data so that it is easier for others to understand your issue, replicate it, and solve the problem.
              sure thing, will do next time! thanks!

              Comment

              Working...
              X