Announcement

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

  • Using xtile to create 4 groups of a continuous variable however these groups need to be adjusted for age and sex

    Can we use xtile to create 4 groups of a continuous variable however these groups need to be adjusted for age and sex in a way representing the distribution of sex and age. If xtile command is not the right way to accomplish the above can someone suggest a method for that?

  • #2
    Do you mean that the age and sex distribution in each of the 4 groups must be (at least approximately) the same as the overall age and sex distribution of the sample? If so, it may or may not be possible. If the continuous variable's distribution is independent of age and sex, then yes, in principle, you could use -xtile- for this purpose. But remember that -xtile- generates quartiles, so if the variable's distribution is not independent of age and sex then the distributions of age and sex in each quartile would necessarily be different.

    Comment


    • #3
      The variable's distribution is not independent of age and sex. My goal is to create 2-4 groups of that particulaer variable (using ranking or other) with as approximate as possable represention of the distrbution of age and sex. I am trying to find a way to do that in Stata.

      Comment


      • #4
        I still don't understand what you want to do. Do you just want to divide the data set up into two to four groups each of which is more or less representative of the distribution of age and sex, and whatever values of the continuous variable you get are fine? Since you originally suggested using -xtile- I inferred that you wanted the groups to at least approximately represent quartiles of that variable.

        In any case, if, after making it clearer what you want, you need help with code, you need to show example data. Please be sure to use the -dataex- command to do that. If you are running version 15.1 or a fully updated version 14.2, it is already part of your official Stata installation. If not, run -ssc install dataex- to get it. Either way, run -help dataex- to read the simple instructions for using it. -dataex- will save you time; it is easier and quicker than typing out tables. It includes complete information about aspects of the data that are often critical to answering your question but cannot be seen from tabular displays or screenshots. It also makes it possible for those who want to help you to create a faithful representation of your example to try out their code, which in turn makes it more likely that their answer will actually work in your data.

        When asking for help with code, always show example data. When showing example data, always use -dataex-.

        Comment

        Working...
        X