Statalist


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: st: Alphabetical sort by value label


From   "David Elliott" <[email protected]>
To   [email protected]
Subject   Re: st: Alphabetical sort by value label
Date   Wed, 17 Dec 2008 13:04:43 -0400

Sergiy, thank you.  Your routine does fulfill part of the requirement
in allowing data to be sorted in label alphabetical order.  However,
the other requirement of alphabetical ordering in tables is not met.
The merge method is surprisingly quick compared to the recode.  I ran
my routine and yours with -profiler on- and it was faster despite the
preserve,sort and merge steps.  I will consider refactoring my code in
light of this although I would still like to be able to do the
recoding within mata, or save the sorted matrix with old and new
values to a .dta file capable of being merged.  More poring over the
manual is in order, obviously.

If you are interested - here are the profiler reports:

. set memory 500m
. sysuse nlsw88.dta, clear
. expand 1000
. profiler on
. labvalsort industry

. profiler report
labvalsort
     1    0.218  labvalsort
recode
     1   24.437  recode
    24    0.000  GetEl
    12    0.000  CheckParens
         24.437  Total
unab
     1    0.000  unab
label
     5    0.000  label
recast
     1    1.344  recast
move
     1    0.297  move
lab
     1    0.000  lab
Overall total count =     47
Overall total time  =     26.296 (sec)

. profiler clear

labels_ABC industry
. profiler report
labels_ABC
     1   11.734  labels_ABC
uselabel
     1    0.000  uselabel
     1    0.000  Uselabel_u
          0.000  Total
label
     3    0.000  label
merge
     1    1.797  merge
unab
     1    0.000  unab
Overall total count =      8
Overall total time  =     13.531 (sec)

Clearly recode may not be the command to use.

DCE
*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/



© Copyright 1996–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index