Announcement

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

  • Sort a variable by id

    Hi,
    In the following example, I want to sort the variable DACC by ISIN (company identification).

    I am using "sort DACC, stable" but I don't know how to fit "by ISIN" here.

    I would be grateful you help me to correct the command.

    Best rgerads,
    Mahmoud

    example:
    Code:
    * Example generated by -dataex-. To install: ssc install dataex
    clear
    input str12 ISIN float(DACC revenues)
    "SE0000103699"  -.026326386   3076800
    "SE0000103699"  -.022290224   3178200
    "SE0000103814"   -.08848236  13440450
    "SE0000103814"  -.035057265  12695157
    "SE0000105199"  -.009596745  519832.5
    "SE0000105199"    .01138073  457892.5
    "SE0000106205"   -.06953547 4832581.5
    "SE0000106205"  -.033702917 4858224.5
    "SE0000108227"  -.008480606   8299583
    "SE0000108227"  -.008079009   7650803
    "SE0000109290"    .03796161   1859514
    "SE0000109290"    .06060495 1741226.6
    "SE0000109811"   .007949398  514609.2
    "SE0000109811"  -.007127064  465639.2
    "SE0000112724"    .01964182  12548672
    "SE0000112724"  -.002565005  12281023
    "SE0000113250"   -.05076509  16654772
    "SE0000113250"    .11185604  15217544
    "SE0000114837"   -.03450874 2711464.5
    "SE0000114837"    .11262303   3312445
    "SE0000119299"   .013937738  463639.4
    "SE0000119299"    .01203357  665660.9
    "SE0000163594" -.0034414465   8801111
    "SE0000163594" -.0021055695   9231432
    "SE0000163628"   -.03860267 1223807.6
    "SE0000163628"    -.0693554 1111313.6
    "SE0000171100"   -.02545927   6241037
    "SE0000171100"  .0034898676   5828132
    "SE0000190134"    .02563496  383250.1
    "SE0000190134"  -.014203617  369278.2
    end

  • #2
    sort ISIN DACC will do the trick: you first sort by the first variable, and then within the first variable you sort by the second variable. If you add a third variable you sort within the first two variables, etc.

    I am not a big fan of the stable option: if you are sorting on a variable with ties, then you need to know that and make a informed decision. The stable option tends to hide the problem, but not solve it.
    ---------------------------------
    Maarten L. Buis
    University of Konstanz
    Department of history and sociology
    box 40
    78457 Konstanz
    Germany
    http://www.maartenbuis.nl
    ---------------------------------

    Comment


    • #3
      Thanks Maarten.

      Comment

      Working...
      X