Announcement

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

  • Selecting Maximum Values across variable to create one variable

    Hello,

    I have a dataset of which contains a GP practice in one column and the proportion of total referrals to a given hospital in a set of 30 other variables (not all 30 hospitals are in the sample data below). The hospital variables all start with neurosurg_provider* . The values for these hospitals are between 0 and 1. I have created a new variable(not in the sample data below):

    egen max=rowmax( neurosurg_provider_RTH - neurosurg_provider_RM3 )

    What I would like to do is create a single variable (Main_Prov), which is the hospital name, for the hospital with the highest value for that observation. I can then encode that variable and use it in subsequent analysis. So for the first observation in the sample data below, neurosurg_provider_RET would be the value for the Main_Prov variable, because it has the highest value (1) for that observation across the row of hospitals.

    I am having difficulty coming up with the code to do and was hoping someone might have some suggestions or advice? Where there is a tie, e.g. in the unlikely even we have two hospitals for an observation with .5 in each, then it doesn't matter which one is chosen for the main provider.

    clear
    input str6 GPCode double(neurosurg_provider_RTH neurosurg_provider_RJE neurosurg_provider_RWW neurosurg_provider_RAP neurosurg_provider_RRK neurosurg_provider_RWA neurosurg_provider_RRV neurosurg_provider_RET neurosurg_provider_RR8)
    "N85040" 0 0 0 0 0 0 0 1 0
    "B87040" 0 0 0 0 0 0 0 0 .8666666666666667
    "D81035" 0 0 0 0 0 0 0 0 0
    "G85082" 0 0 0 0 0 0 .2 0 0
    "D83053" 0 0 0 0 0 0 0 .14285714285714285 0
    "A83045" 0 0 0 0 0 0 0 0 .022727272727272728
    "A86026" 0 0 0 0 0 0 0 0 0
    "A87003" 0 0 0 0 0 0 0 .022727272727272728 0
    "B81666" 0 0 0 0 0 .8571428571428571 0 0 0
    "B86018" 0 0 0 0 0 0 0 0 .9523809523809523
    "K81040" .9411764705882353 0 0 0 0 0 0 0 0
    "M86015" .09090909090909091 0 0 0 0 0 0 0 0
    "J81053" 0 0 0 0 0 0 .14285714285714285 0 0
    "B82106" 0 0 0 0 0 .8571428571428571 0 0 0
    "F83045" 0 0 0 0 0 0 .8275862068965517 0 0
    "C87620" 0 0 0 0 0 0 0 0 .045454545454545456
    "D81013" 0 0 0 0 0 0 0 0 0
    "G83009" 0 0 0 0 0 0 .08571428571428572 0 0
    "M92649" 0 .16666666666666666 0 0 .8333333333333334 0 0 0 0
    "N84017" 0 0 0 0 0 0 0 .9770114942528736 0
    "L83071" .02127659574468085 0 0 0 0 0 .02127659574468085 0 0
    "C84131" 0 0 0 0 0 0 0 0 0
    "G83049" 0 0 0 0 0 0 .022727272727272728 0 0
    "E81009" .08333333333333333 0 0 0 0 0 .625 0 0
    "A87015" 0 0 0 0 0 0 0 0 0
    "B85026" 0 0 0 0 0 0 0 0 .7419354838709677
    "B86052" 0 0 0 0 0 0 0 .047619047619047616 .9285714285714286
    "G82046" 0 0 0 0 0 0 0 0 0
    "G82051" 0 0 0 0 0 0 .075 0 0
    "H82089" 0 0 0 0 0 0 .04 0 0
    "M92007" 0 .11764705882352941 0 0 .8235294117647058 0 0 0 0
    "P82007" 0 0 0 0 0 0 .008547008547008548 .017094017094017096 0
    "F86692" 0 0 0 0 0 0 .05714285714285714 0 0
    "K82618" 1 0 0 0 0 0 0 0 0
    "L81008" 0 0 0 0 0 0 0 0 0
    "C83045" .022727272727272728 0 0 0 0 .11363636363636363 .022727272727272728 0 .022727272727272728
    "C86011" 0 0 0 0 0 0 .02127659574468085 0 .02127659574468085
    "D81065" 0 0 0 0 0 0 0 0 0
    "H83049" 0 0 0 0 0 0 .2857142857142857 0 0
    "M86005" .13333333333333333 0 0 0 0 0 0 0 0
    "J82166" 0 0 0 0 0 0 0 0 0
    "F82008" 0 0 0 0 0 0 .05102040816326531 0 0
    "L83113" 0 0 0 0 0 0 0 0 0
    "M83024" 0 .8378378378378378 0 0 .08108108108108109 0 0 .02702702702702703 0
    "Y03661" 0 0 0 0 0 0 0 0 0
    "M84627" .037037037037037035 0 0 0 .037037037037037035 0 .07407407407407407 0 0
    "M87020" .038461538461538464 .038461538461538464 0 0 .8846153846153846 0 0 0 0
    "N81115" 0 .025 0 0 0 0 0 .925 0
    "A82034" 0 0 0 0 0 0 .008547008547008548 .02564102564102564 .008547008547008548
    "J82053" 0 0 0 0 0 0 0 0 0
    "J83058" 0 0 0 0 .1111111111111111 0 .1111111111111111 0 0
    "M81617" .043478260869565216 .08695652173913043 0 0 .2608695652173913 0 0 0 0
    "N83001" 0 0 0 0 0 0 0 .9056603773584906 0
    "P82012" 0 0 0 0 0 0 0 0 0
    "L81077" 0 0 0 0 0 0 0 0 0
    "L81118" 0 0 0 0 0 0 0 0 0
    "L82041" 0 0 0 0 .008695652173913044 0 .02608695652173913 0 0
    "L83066" 0 0 0 0 0 0 .09090909090909091 0 0
    "M84064" 0 .047619047619047616 0 0 .09523809523809523 0 .047619047619047616 0 0
    "M88030" 0 0 0 0 1 0 0 0 0
    "J81030" .07142857142857142 0 0 0 0 0 0 0 0
    "J81616" 0 0 0 0 0 0 0 0 0
    "N82646" 0 0 0 0 0 0 0 .9333333333333333 0
    "K84060" .7619047619047619 0 0 0 0 .047619047619047616 0 0 0
    "L85025" 0 0 0 0 0 0 .08333333333333333 0 0
    "G85132" 0 0 0 0 0 0 .07692307692307693 0 0
    "H82009" .01694915254237288 0 0 0 0 0 .01694915254237288 0 0
    "B82005" 0 0 0 0 .004424778761061947 .6769911504424779 .004424778761061947 0 .24336283185840707
    "E85677" 0 0 0 0 0 0 .16666666666666666 0 0
    "F82679" 0 0 0 0 0 0 0 0 0
    "F86712" 0 0 0 0 0 0 0 0 0
    "P87017" 0 0 0 0 0 0 0 0 0
    "Y00110" 0 0 0 0 0 0 0 1 0
    "C83018" 0 0 0 0 0 .39473684210526316 0 0 .02631578947368421
    "D83070" 0 0 0 0 0 0 0 0 0
    "H81025" 0 0 0 0 0 0 .04 0 0
    "A82060" .0020477815699658703 .0013651877133105802 0 0 .0006825938566552901 .0006825938566552901 .004095563139931741 .031399317406143344 .0020477815699658703
    "A85011" 0 0 0 0 0 0 0 0 0
    "K81050" .75 0 0 0 0 0 0 0 0
    "C88032" 0 0 0 0 0 0 0 0 0
    "M83066" 0 .8636363636363636 0 0 .022727272727272728 0 0 .022727272727272728 0
    "H81064" 0 0 0 0 0 0 .08333333333333333 0 0
    "A87008" 0 0 0 0 0 0 0 0 0
    "N82104" 0 0 0 0 0 0 0 1 0
    "P83020" 0 .0037593984962406013 0 0 0 0 0 .011278195488721804 0
    "C81009" 0 0 0 0 .058823529411764705 0 0 0 0
    "F82003" 0 0 0 0 0 0 .041666666666666664 0 0
    "P91018" 0 0 0 0 0 0 0 0 0
    "G84032" 0 0 0 0 0 0 .03333333333333333 0 0
    "A81038" 0 0 0 0 0 0 0 0 0
    "A82650" 0 0 0 0 0 0 0 .03076923076923077 0
    "L83011" 0 0 0 0 0 0 0 0 0
    "C84105" 0 0 0 0 0 0 0 0 0
    "G82754" 0 0 0 0 0 0 0 0 0
    "M83041" .041666666666666664 0 0 0 .9166666666666666 0 0 0 0
    "P82004" 0 0 0 0 0 0 0 0 0
    "L83100" 0 0 0 0 0 0 .011583011583011582 0 0
    "C83013" 0 0 0 0 .03333333333333333 .06666666666666667 0 0 0
    "C84660" 0 0 0 0 .09090909090909091 0 0 0 0
    "C85007" 0 0 0 0 0 0 0 0 .05555555555555555
    end
    [/CODE]
    ------------------ copy up to and including the previous line ------------------


  • #2
    And what do you want to happen when two or more hospitals share the maximum value of referrals?

    Check out in any case the user written -rowranks-.

    Code:
    net describe rowranks, from(http://fmwww.bc.edu/RePEc/bocode/r)

    Comment


    • #3
      rowranks on SSC has been superseded by rowranks from the Stata Journal.

      More to the point of #1 is a paper dedicated to exactly this problem at https://journals.sagepub.com/doi/pdf...36867X20931007

      Comment


      • #4
        Hello,

        Apologies in advance - I wrote the below on a different, but related thread by mistake. I have copied it here because it makes more sense here.

        I wrote some code based on a previous post with a similar problem. However, it only seems to populate the variable name for some observations:

        local vars "neurosurg_provider_RTH neurosurg_provider_RJE neurosurg_provider_RWW neurosurg_provider_RAP neurosurg_provider_RRK neurosurg_provider_RWA neurosurg_provider_RRV neurosurg_provider_RET neurosurg_provider_RR8 neurosurg_provider_RTR neurosurg_provider_RF4 neurosurg_provider_RVJ neurosurg_provider_RJ7 neurosurg_provider_RBN neurosurg_provider_RXH neurosurg_provider_RTD neurosurg_provider_RHQ neurosurg_provider_RGT neurosurg_provider_RYJ neurosurg_provider_RX1 neurosurg_provider_RLT neurosurg_provider_RXN neurosurg_provider_R1E neurosurg_provider_R1H neurosurg_provider_RKB neurosurg_provider_RM2 neurosurg_provider_RHM neurosurg_provider_RJZ neurosurg_provider_RK9 neurosurg_provider_RM3"

        egen m2= rowmax( `vars' )
        gen m=""

        foreach var of local vars {
        replace m = "`var'" if m2==`var'


        }
        drop m2

        Does anyone know what is happening and how to amend the code?

        The output is below:

        Code:
        * Example generated by -dataex-. To install: ssc install dataex clear input str6 GPCode double(neurosurg_provider_RTH neurosurg_provider_RJE neurosurg_provider_RWW neurosurg_provider_RAP neurosurg_provider_RRK neurosurg_provider_RWA neurosurg_provider_RRV neurosurg_provider_RET neurosurg_provider_RR8) str22 m "N85040" 0 0 0 0 0 0 0 1 0 "neurosurg_provider_RET" "B87040" 0 0 0 0 0 0 0 0 .8666666666666667 "" "D81035" 0 0 0 0 0 0 0 0 0 "neurosurg_provider_RGT" "G85082" 0 0 0 0 0 0 .2 0 0 "" "D83053" 0 0 0 0 0 0 0 .14285714285714285 0 "" "A83045" 0 0 0 0 0 0 0 0 .022727272727272728 "" "A86026" 0 0 0 0 0 0 0 0 0 "neurosurg_provider_RTD" "A87003" 0 0 0 0 0 0 0 .022727272727272728 0 "" "B81666" 0 0 0 0 0 .8571428571428571 0 0 0 "" "B86018" 0 0 0 0 0 0 0 0 .9523809523809523 "" "K81040" .9411764705882353 0 0 0 0 0 0 0 0 "" "M86015" .09090909090909091 0 0 0 0 0 0 0 0 "" "J81053" 0 0 0 0 0 0 .14285714285714285 0 0 "" "B82106" 0 0 0 0 0 .8571428571428571 0 0 0 "" "F83045" 0 0 0 0 0 0 .8275862068965517 0 0 "" "C87620" 0 0 0 0 0 0 0 0 .045454545454545456 "" "D81013" 0 0 0 0 0 0 0 0 0 "" "G83009" 0 0 0 0 0 0 .08571428571428572 0 0 "" "M92649" 0 .16666666666666666 0 0 .8333333333333334 0 0 0 0 "" "N84017" 0 0 0 0 0 0 0 .9770114942528736 0 "" "L83071" .02127659574468085 0 0 0 0 0 .02127659574468085 0 0 "" "C84131" 0 0 0 0 0 0 0 0 0 "" "G83049" 0 0 0 0 0 0 .022727272727272728 0 0 "" "E81009" .08333333333333333 0 0 0 0 0 .625 0 0 "neurosurg_provider_RRV" "A87015" 0 0 0 0 0 0 0 0 0 "" "B85026" 0 0 0 0 0 0 0 0 .7419354838709677 "" "B86052" 0 0 0 0 0 0 0 .047619047619047616 .9285714285714286 "" "G82046" 0 0 0 0 0 0 0 0 0 "neurosurg_provider_RJZ" "G82051" 0 0 0 0 0 0 .075 0 0 "" "H82089" 0 0 0 0 0 0 .04 0 0 "" "M92007" 0 .11764705882352941 0 0 .8235294117647058 0 0 0 0 "" "P82007" 0 0 0 0 0 0 .008547008547008548 .017094017094017096 0 "" "F86692" 0 0 0 0 0 0 .05714285714285714 0 0 "" "K82618" 1 0 0 0 0 0 0 0 0 "neurosurg_provider_RTH" "L81008" 0 0 0 0 0 0 0 0 0 "neurosurg_provider_RVJ" "C83045" .022727272727272728 0 0 0 0 .11363636363636363 .022727272727272728 0 .022727272727272728 "" "C86011" 0 0 0 0 0 0 .02127659574468085 0 .02127659574468085 "" "D81065" 0 0 0 0 0 0 0 0 0 "neurosurg_provider_RGT" "H83049" 0 0 0 0 0 0 .2857142857142857 0 0 "" "M86005" .13333333333333333 0 0 0 0 0 0 0 0 "" "J82166" 0 0 0 0 0 0 0 0 0 "" "F82008" 0 0 0 0 0 0 .05102040816326531 0 0 "" "L83113" 0 0 0 0 0 0 0 0 0 "" "M83024" 0 .8378378378378378 0 0 .08108108108108109 0 0 .02702702702702703 0 "" "Y03661" 0 0 0 0 0 0 0 0 0 "neurosurg_provider_RHM" "M84627" .037037037037037035 0 0 0 .037037037037037035 0 .07407407407407407 0 0 "" "M87020" .038461538461538464 .038461538461538464 0 0 .8846153846153846 0 0 0 0 "" "N81115" 0 .025 0 0 0 0 0 .925 0 "" "A82034" 0 0 0 0 0 0 .008547008547008548 .02564102564102564 .008547008547008548 "" "J82053" 0 0 0 0 0 0 0 0 0 "neurosurg_provider_RHM" "J83058" 0 0 0 0 .1111111111111111 0 .1111111111111111 0 0 "" "M81617" .043478260869565216 .08695652173913043 0 0 .2608695652173913 0 0 0 0 "" "N83001" 0 0 0 0 0 0 0 .9056603773584906 0 "" "P82012" 0 0 0 0 0 0 0 0 0 "" "L81077" 0 0 0 0 0 0 0 0 0 "neurosurg_provider_RVJ" "L81118" 0 0 0 0 0 0 0 0 0 "neurosurg_provider_RVJ" "L82041" 0 0 0 0 .008695652173913044 0 .02608695652173913 0 0 "" "L83066" 0 0 0 0 0 0 .09090909090909091 0 0 "" "M84064" 0 .047619047619047616 0 0 .09523809523809523 0 .047619047619047616 0 0 "" "M88030" 0 0 0 0 1 0 0 0 0 "neurosurg_provider_RRK" "J81030" .07142857142857142 0 0 0 0 0 0 0 0 "" "J81616" 0 0 0 0 0 0 0 0 0 "neurosurg_provider_RHM" "N82646" 0 0 0 0 0 0 0 .9333333333333333 0 "" "K84060" .7619047619047619 0 0 0 0 .047619047619047616 0 0 0 "" "L85025" 0 0 0 0 0 0 .08333333333333333 0 0 "" "G85132" 0 0 0 0 0 0 .07692307692307693 0 0 "" "H82009" .01694915254237288 0 0 0 0 0 .01694915254237288 0 0 "" "B82005" 0 0 0 0 .004424778761061947 .6769911504424779 .004424778761061947 0 .24336283185840707 "" "E85677" 0 0 0 0 0 0 .16666666666666666 0 0 "" "F82679" 0 0 0 0 0 0 0 0 0 "" "F86712" 0 0 0 0 0 0 0 0 0 "neurosurg_provider_R1H" "P87017" 0 0 0 0 0 0 0 0 0 "neurosurg_provider_RM3" "Y00110" 0 0 0 0 0 0 0 1 0 "neurosurg_provider_RET" "C83018" 0 0 0 0 0 .39473684210526316 0 0 .02631578947368421 "" "D83070" 0 0 0 0 0 0 0 0 0 "" "H81025" 0 0 0 0 0 0 .04 0 0 "" "A82060" .0020477815699658703 .0013651877133105802 0 0 .0006825938566552901 .0006825938566552901 .004095563139931741 .031399317406143344 .0020477815699658703 "" "A85011" 0 0 0 0 0 0 0 0 0 "" "K81050" .75 0 0 0 0 0 0 0 0 "neurosurg_provider_RTH" "C88032" 0 0 0 0 0 0 0 0 0 "neurosurg_provider_RHQ" "M83066" 0 .8636363636363636 0 0 .022727272727272728 0 0 .022727272727272728 0 "" "H81064" 0 0 0 0 0 0 .08333333333333333 0 0 "" "A87008" 0 0 0 0 0 0 0 0 0 "neurosurg_provider_RTD" "N82104" 0 0 0 0 0 0 0 1 0 "neurosurg_provider_RET" "P83020" 0 .0037593984962406013 0 0 0 0 0 .011278195488721804 0 "" "C81009" 0 0 0 0 .058823529411764705 0 0 0 0 "" "F82003" 0 0 0 0 0 0 .041666666666666664 0 0 "" "P91018" 0 0 0 0 0 0 0 0 0 "" "G84032" 0 0 0 0 0 0 .03333333333333333 0 0 "" "A81038" 0 0 0 0 0 0 0 0 0 "neurosurg_provider_RTR" "A82650" 0 0 0 0 0 0 0 .03076923076923077 0 "" "L83011" 0 0 0 0 0 0 0 0 0 "" "C84105" 0 0 0 0 0 0 0 0 0 "" "G82754" 0 0 0 0 0 0 0 0 0 "neurosurg_provider_RJZ" "M83041" .041666666666666664 0 0 0 .9166666666666666 0 0 0 0 "" "P82004" 0 0 0 0 0 0 0 0 0 "" "L83100" 0 0 0 0 0 0 .011583011583011582 0 0 "" "C83013" 0 0 0 0 .03333333333333333 .06666666666666667 0 0 0 "" "C84660" 0 0 0 0 .09090909090909091 0 0 0 0 "" "C85007" 0 0 0 0 0 0 0 0 .05555555555555555 "" end

        Comment


        • #5
          OP already found the relevant thread and bumped it up; but whoever encounters this thread -- I gave a bad reference, I am sorry. I have never used the user written -rowranks-, and I incorrectly thought that -rowranks- does for all ranks what Nick describes on page 484 in the reference he gives in #3 for min and max.

          Andrew proposes similar solution in #3 for the max on this thread here https://www.statalist.org/forums/for...ariables-names
          which OP already found out.

          Comment


          • #6
            OP, I cannot import your data. Please try to post it again in a proper format.

            Otherwise the code in #4 seems correct.

            Comment


            • #7
              Here is the data - not sure what happened when I posted it before.

              Code:
              * Example generated by -dataex-. To install: ssc install dataex
              clear
              input str6 GPCode double(neurosurg_provider_RTH neurosurg_provider_RJE neurosurg_provider_RWW neurosurg_provider_RAP neurosurg_provider_RRK neurosurg_provider_RWA neurosurg_provider_RRV neurosurg_provider_RET neurosurg_provider_RR8) str22 m
              "N85040"                    0                    0 0 0                    0                    0                   0                   1                    0 "neurosurg_provider_RET"
              "B87040"                    0                    0 0 0                    0                    0                   0                   0    .8666666666666667 ""                      
              "D81035"                    0                    0 0 0                    0                    0                   0                   0                    0 "neurosurg_provider_RGT"
              "G85082"                    0                    0 0 0                    0                    0                  .2                   0                    0 ""                      
              "D83053"                    0                    0 0 0                    0                    0                   0  .14285714285714285                    0 ""                      
              "A83045"                    0                    0 0 0                    0                    0                   0                   0  .022727272727272728 ""                      
              "A86026"                    0                    0 0 0                    0                    0                   0                   0                    0 "neurosurg_provider_RTD"
              "A87003"                    0                    0 0 0                    0                    0                   0 .022727272727272728                    0 ""                      
              "B81666"                    0                    0 0 0                    0    .8571428571428571                   0                   0                    0 ""                      
              "B86018"                    0                    0 0 0                    0                    0                   0                   0    .9523809523809523 ""                      
              "K81040"    .9411764705882353                    0 0 0                    0                    0                   0                   0                    0 ""                      
              "M86015"   .09090909090909091                    0 0 0                    0                    0                   0                   0                    0 ""                      
              "J81053"                    0                    0 0 0                    0                    0  .14285714285714285                   0                    0 ""                      
              "B82106"                    0                    0 0 0                    0    .8571428571428571                   0                   0                    0 ""                      
              "F83045"                    0                    0 0 0                    0                    0   .8275862068965517                   0                    0 ""                      
              "C87620"                    0                    0 0 0                    0                    0                   0                   0  .045454545454545456 ""                      
              "D81013"                    0                    0 0 0                    0                    0                   0                   0                    0 ""                      
              "G83009"                    0                    0 0 0                    0                    0  .08571428571428572                   0                    0 ""                      
              "M92649"                    0   .16666666666666666 0 0    .8333333333333334                    0                   0                   0                    0 ""                      
              "N84017"                    0                    0 0 0                    0                    0                   0   .9770114942528736                    0 ""                      
              "L83071"   .02127659574468085                    0 0 0                    0                    0  .02127659574468085                   0                    0 ""                      
              "C84131"                    0                    0 0 0                    0                    0                   0                   0                    0 ""                      
              "G83049"                    0                    0 0 0                    0                    0 .022727272727272728                   0                    0 ""                      
              "E81009"   .08333333333333333                    0 0 0                    0                    0                .625                   0                    0 "neurosurg_provider_RRV"
              "A87015"                    0                    0 0 0                    0                    0                   0                   0                    0 ""                      
              "B85026"                    0                    0 0 0                    0                    0                   0                   0    .7419354838709677 ""                      
              "B86052"                    0                    0 0 0                    0                    0                   0 .047619047619047616    .9285714285714286 ""                      
              "G82046"                    0                    0 0 0                    0                    0                   0                   0                    0 "neurosurg_provider_RJZ"
              "G82051"                    0                    0 0 0                    0                    0                .075                   0                    0 ""                      
              "H82089"                    0                    0 0 0                    0                    0                 .04                   0                    0 ""                      
              "M92007"                    0   .11764705882352941 0 0    .8235294117647058                    0                   0                   0                    0 ""                      
              "P82007"                    0                    0 0 0                    0                    0 .008547008547008548 .017094017094017096                    0 ""                      
              "F86692"                    0                    0 0 0                    0                    0  .05714285714285714                   0                    0 ""                      
              "K82618"                    1                    0 0 0                    0                    0                   0                   0                    0 "neurosurg_provider_RTH"
              "L81008"                    0                    0 0 0                    0                    0                   0                   0                    0 "neurosurg_provider_RVJ"
              "C83045"  .022727272727272728                    0 0 0                    0   .11363636363636363 .022727272727272728                   0  .022727272727272728 ""                      
              "C86011"                    0                    0 0 0                    0                    0  .02127659574468085                   0   .02127659574468085 ""                      
              "D81065"                    0                    0 0 0                    0                    0                   0                   0                    0 "neurosurg_provider_RGT"
              "H83049"                    0                    0 0 0                    0                    0   .2857142857142857                   0                    0 ""                      
              "M86005"   .13333333333333333                    0 0 0                    0                    0                   0                   0                    0 ""                      
              "J82166"                    0                    0 0 0                    0                    0                   0                   0                    0 ""                      
              "F82008"                    0                    0 0 0                    0                    0  .05102040816326531                   0                    0 ""                      
              "L83113"                    0                    0 0 0                    0                    0                   0                   0                    0 ""                      
              "M83024"                    0    .8378378378378378 0 0   .08108108108108109                    0                   0  .02702702702702703                    0 ""                      
              "Y03661"                    0                    0 0 0                    0                    0                   0                   0                    0 "neurosurg_provider_RHM"
              "M84627"  .037037037037037035                    0 0 0  .037037037037037035                    0  .07407407407407407                   0                    0 ""                      
              "M87020"  .038461538461538464  .038461538461538464 0 0    .8846153846153846                    0                   0                   0                    0 ""                      
              "N81115"                    0                 .025 0 0                    0                    0                   0                .925                    0 ""                      
              "A82034"                    0                    0 0 0                    0                    0 .008547008547008548  .02564102564102564  .008547008547008548 ""                      
              "J82053"                    0                    0 0 0                    0                    0                   0                   0                    0 "neurosurg_provider_RHM"
              "J83058"                    0                    0 0 0    .1111111111111111                    0   .1111111111111111                   0                    0 ""                      
              "M81617"  .043478260869565216   .08695652173913043 0 0    .2608695652173913                    0                   0                   0                    0 ""                      
              "N83001"                    0                    0 0 0                    0                    0                   0   .9056603773584906                    0 ""                      
              "P82012"                    0                    0 0 0                    0                    0                   0                   0                    0 ""                      
              "L81077"                    0                    0 0 0                    0                    0                   0                   0                    0 "neurosurg_provider_RVJ"
              "L81118"                    0                    0 0 0                    0                    0                   0                   0                    0 "neurosurg_provider_RVJ"
              "L82041"                    0                    0 0 0  .008695652173913044                    0  .02608695652173913                   0                    0 ""                      
              "L83066"                    0                    0 0 0                    0                    0  .09090909090909091                   0                    0 ""                      
              "M84064"                    0  .047619047619047616 0 0   .09523809523809523                    0 .047619047619047616                   0                    0 ""                      
              "M88030"                    0                    0 0 0                    1                    0                   0                   0                    0 "neurosurg_provider_RRK"
              "J81030"   .07142857142857142                    0 0 0                    0                    0                   0                   0                    0 ""                      
              "J81616"                    0                    0 0 0                    0                    0                   0                   0                    0 "neurosurg_provider_RHM"
              "N82646"                    0                    0 0 0                    0                    0                   0   .9333333333333333                    0 ""                      
              "K84060"    .7619047619047619                    0 0 0                    0  .047619047619047616                   0                   0                    0 ""                      
              "L85025"                    0                    0 0 0                    0                    0  .08333333333333333                   0                    0 ""                      
              "G85132"                    0                    0 0 0                    0                    0  .07692307692307693                   0                    0 ""                      
              "H82009"   .01694915254237288                    0 0 0                    0                    0  .01694915254237288                   0                    0 ""                      
              "B82005"                    0                    0 0 0  .004424778761061947    .6769911504424779 .004424778761061947                   0   .24336283185840707 ""                      
              "E85677"                    0                    0 0 0                    0                    0  .16666666666666666                   0                    0 ""                      
              "F82679"                    0                    0 0 0                    0                    0                   0                   0                    0 ""                      
              "F86712"                    0                    0 0 0                    0                    0                   0                   0                    0 "neurosurg_provider_R1H"
              "P87017"                    0                    0 0 0                    0                    0                   0                   0                    0 "neurosurg_provider_RM3"
              "Y00110"                    0                    0 0 0                    0                    0                   0                   1                    0 "neurosurg_provider_RET"
              "C83018"                    0                    0 0 0                    0   .39473684210526316                   0                   0   .02631578947368421 ""                      
              "D83070"                    0                    0 0 0                    0                    0                   0                   0                    0 ""                      
              "H81025"                    0                    0 0 0                    0                    0                 .04                   0                    0 ""                      
              "A82060" .0020477815699658703 .0013651877133105802 0 0 .0006825938566552901 .0006825938566552901 .004095563139931741 .031399317406143344 .0020477815699658703 ""                      
              "A85011"                    0                    0 0 0                    0                    0                   0                   0                    0 ""                      
              "K81050"                  .75                    0 0 0                    0                    0                   0                   0                    0 "neurosurg_provider_RTH"
              "C88032"                    0                    0 0 0                    0                    0                   0                   0                    0 "neurosurg_provider_RHQ"
              "M83066"                    0    .8636363636363636 0 0  .022727272727272728                    0                   0 .022727272727272728                    0 ""                      
              "H81064"                    0                    0 0 0                    0                    0  .08333333333333333                   0                    0 ""                      
              "A87008"                    0                    0 0 0                    0                    0                   0                   0                    0 "neurosurg_provider_RTD"
              "N82104"                    0                    0 0 0                    0                    0                   0                   1                    0 "neurosurg_provider_RET"
              "P83020"                    0 .0037593984962406013 0 0                    0                    0                   0 .011278195488721804                    0 ""                      
              "C81009"                    0                    0 0 0  .058823529411764705                    0                   0                   0                    0 ""                      
              "F82003"                    0                    0 0 0                    0                    0 .041666666666666664                   0                    0 ""                      
              "P91018"                    0                    0 0 0                    0                    0                   0                   0                    0 ""                      
              "G84032"                    0                    0 0 0                    0                    0  .03333333333333333                   0                    0 ""                      
              "A81038"                    0                    0 0 0                    0                    0                   0                   0                    0 "neurosurg_provider_RTR"
              "A82650"                    0                    0 0 0                    0                    0                   0  .03076923076923077                    0 ""                      
              "L83011"                    0                    0 0 0                    0                    0                   0                   0                    0 ""                      
              "C84105"                    0                    0 0 0                    0                    0                   0                   0                    0 ""                      
              "G82754"                    0                    0 0 0                    0                    0                   0                   0                    0 "neurosurg_provider_RJZ"
              "M83041"  .041666666666666664                    0 0 0    .9166666666666666                    0                   0                   0                    0 ""                      
              "P82004"                    0                    0 0 0                    0                    0                   0                   0                    0 ""                      
              "L83100"                    0                    0 0 0                    0                    0 .011583011583011582                   0                    0 ""                      
              "C83013"                    0                    0 0 0   .03333333333333333   .06666666666666667                   0                   0                    0 ""                      
              "C84660"                    0                    0 0 0   .09090909090909091                    0                   0                   0                    0 ""                      
              "C85007"                    0                    0 0 0                    0                    0                   0                   0   .05555555555555555 ""                      
              end

              Comment


              • #8
                Your row maximum is presumably being generated as a float. Comparing doubles and floats can be tricky for non-integer arguments, as each double carries more bits than the corresponding float. and what "should be" equal then isn't.

                The easiest fix is to go

                Code:
                egen double m2= rowmax(`vars')

                Comment


                • #9
                  See also https://www.statalist.org/forums/for...ariables-names

                  Daniel Sutcliffe If you feel the need to post in two or more threads at the same time, it is essential to flag with explicit links.

                  Comment

                  Working...
                  X