Announcement

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

  • Convert variable to percentile

    How can I convert values of a variable to percentiles ranging from 1-99?

    I have tried pctile but it does not give the correct results.
    Last edited by Gary Zhang; 17 Jun 2019, 10:32.

  • #2
    Hi Gary, can you first list the incorrect example with pctile first?
    2B or not 2B, that's a question!

    Comment


    • #3
      Hi, I am trying the example on page 3 here:

      https://www.stata.com/manuals13/dpctile.pdf

      How do I get it to create a variable that shows for example, the observation with mpg = 41 to be 100th percentile, and observation with mpg = 12 to be 0 percentile?
      Thanks.

      Comment


      • #4
        Your request is very strange. Can you first define what a 0 percentile is?
        2B or not 2B, that's a question!

        Comment


        • #5
          Sorry, I meant from 1 to 99.

          Comment


          • #6
            Hi Gary, try:

            Code:
            xtile newvar = oldvar,nq(100)

            Comment


            • #7
              Originally posted by Igor Paploski View Post
              Hi Gary, try:

              Code:
              xtile newvar = oldvar,nq(100)
              Yes the results look correct now. Thanks

              Comment


              • #8
                See also https://www.stata.com/support/faqs/s...ing-positions/

                Comment

                Working...
                X