Statalist


[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: Forcing sort order in graph box, over() by()


From   Stefan Kreisel <kreisel.stefan@web.de>
To   statalist@hsphsun2.harvard.edu
Subject   st: Forcing sort order in graph box, over() by()
Date   Thu, 23 Aug 2007 14:05:28 +0200

I want to "graph box" a variable that comes in two major groups (say A and B) over several subgroups (say 1 to 5) -> {graph box yvar, over(subgroup) by("major group")}. All things fine. Now adding complexity, I've created a variable (_sort) that sorts the yvar by its median in each subgroup in major group A only; I copy the sorting variable to the major group B and its subgroups 1 to 5 (identical to those in "major group" A). Adding to the graph syntax I get -> graph box yvar, over(subgroup, sort(_sort) by("major group"). Works fine again: the "graph box" by A and B are sorted according to the medians of subgroups in major group A. Problems do arise, however, if there are no cases of yvar in a given subgroup in major group B, for example. The resulting graph puts the missing subgroup category as a label on the far right side. For visual purposes, however, the missing subgroup category of "major group" B should retain the same position as on the "major group" A side of the gra
 
 ph. Differential sorting when using "by" seems to work nonetheless. For example, if one does {graph box yvar, over(subgroup, sort(1)) by("major group")}, "major groups" A and B get sorted according to their respective medians, with empty categories now on the left side (hm?). The question is how do I manually control the position of "over(subgroup)" when using by("major group"), when there are missing categories in one of the subgroups?
Regards.
Stefan Kreisel.
*
*   For searches and help try:
*   http://www.stata.com/support/faqs/res/findit.html
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/



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