Announcement

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

  • reshape command not working due to missing values

    Hello everyone,
    I am trying to do a reshape command for a dataset on average wages and on some World Development Indicators. I would like to do a reshape wide command for the WDIDs and that the value of the respective WDID is underneath it. However, by trying the command reshape wide WDID, i(id) j(value) I get the error message that it does not work as the variable value has missing values. Do you know how to overcome this issue? Attached you can find the date editor, in order for you to get an idea on how the dataset is structured. Any help would be highly appreciated!
    Best,
    Adel-Jannes


    Attached Files

  • #2
    It is not clear what you want your reshape command to accomplish.

    The first two observations (2949 and 2950) in your screen capture have values "Labor fo..." and "Literacy..." for WDID and 73.05 and . for value. Your screen shot does not show the full values of WDID, but from what you show, we can guess they are a textual description of the number represented by value.

    When the data is reshaped to wide, what do you expect those two pairs of WDID and value to become in the wide layout? Reshaping wide will result in creating new variables, what do you wish their names to be, and what values do you expect them to take?

    Added in edit, having crossed with post #3:

    In post #1 we see
    Code:
    reshape wide WDID, i(id) j(value)
    which I refrained from commenting on directly, but given post #3 I will say that this command is in fact far from what the reshape command should be, which is why this post asks for the objective of reshaping - to open the door to a discussion of all the problems I see in this command.
    Last edited by William Lisowski; 22 Nov 2021, 10:47.

    Comment


    • #3
      As you do not show the code you used in your attempt to reshape the data, it is impossible to know what might have gone wrong. I know that in the way that I would approach this, missing values in the value variable would not be a problem. And while I could show you the command I would use, without seeing what you did, it may be that I am misunderstanding what you want to do and my command would do something different.

      So please post back showing the command you gave and also show the error message that Stata gave you in response. Be sure to post those exactly, by copying from your Results window or log file directly into the clipboard and from there to the Forum editor. Then wrap the result in code delimiters. Do not edit in any other way--there is no such thing as an unimportant detail in code.

      When you do post back, please show the data in a usable format. Your screenshot happens to be readable, many are not, but even so, if it is necessary to try out code in your data, there is no way to import data from a screenshot. As the Forum FAQ (#12) states, the helpful way to show example data is with the -dataex- command. 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.

      Added: Crossed with #2

      Comment

      Working...
      X