Announcement

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

  • Help

    .
    Attached Files
    Last edited by Sunshine bae; 20 Jul 2022, 13:50.

  • #2
    Code:
    by xhpsu xhnum (v10_06h), sort: gen main_sector = v10_07[_N]
    Notes:
    1. While the descriptive information provided about your data is helpful, it still conveys no information about the data itself, some of which, though not ascertainable with what is shown, affect how one would code the solution. In the future, when asking for help with code, always show example data, and always use the -dataex- command to do that. If you are running version 17, 16 or a fully updated version 15.1 or 14.2, -dataex- 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.

    2. This code will not work correctly if there are observations that have missing values for the variable v10_06h. Good example data would have made it clear whether you face this problem or not. Lacking that information, I have guessed that you do not have that in your data set. If I guessed wrong we have both wasted some time.

    3. The question is somewhat ill-posed. You do not say what to do if in some household(s) there are two or more sectors that have the same total hours spent in them, and that total is higher than for other sectors. The code above will break such ties randomly and irreproducibly--which is probably not what you want. You should either go back and verify that there are no such ties in the data, or, if there are, you should decide on a systematic way of resolving them and adjust the code accordingly.

    Comment


    • #3
      Let me add that it is not helpful to other members, who may seek to learn from the experiences of others, to edit your post and remove your question, so we are left to guess what Clyde's response addresses. It is better to explain how you solved your problem, if indeed you did, or just add a line explaining why the question is no longer relevant.

      Comment

      Working...
      X