Announcement

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

  • drop observations of a variable

    Dear all,

    I use a dataset where employment shares are listed wrt to year and sector (so that I have e.g. 1990 - agriculture - emp. share and some lines later 2000 - agriculture - emp. share).
    Now I would like to drop observations for the employment share variable only (!!!) if year = 1990. How can I do that? I tried "drop emp. share if year = 1990" but it did not work...
    As my dataset contains other variables (per sector as e.g. productivity) for which I am interested in values for 1990, I do not(!) want to use the command drop if year = 1990.
    Is there any possibility to solve my problem?

    Thanks a lot in advance.

  • #2
    An example dataset or sketch of the structure of your data might help us to help you.

    Also note the FAQ concerning cross-posting (http://www.stata-forum.de/stata-synt...ions-t876.html).

    Best
    Daniel

    Comment


    • #3
      Stata datasets are rectangular. You can drop a variable in all observations, and you can drop an observation including all variables, but you cannot drop one or more variables in one or more observations. You can, however change a value to missing.

      Now, we cannot see what you wrote, and we cannot see what Stata responded. "it did not work" leaves quite a bit of guesswork to others. So please, show exactly what you typed, and exactly what Stata responded. You must also show the names of your variables, for example, with the output from the describe command. "emp. share" is an impossible variable name.

      Read the FAQ with good advice on how to use Statalist, including also the good advice to register with your real full name.

      Comment


      • #4
        in addition to Svend's advice, note that what you say you wrote has just one equals sign after the "if"; in Stata, two equals signs are needed there

        Comment


        • #5
          Well one thing we can tell is

          Code:
          drop emp. share if year = 1980
          is illegal in many ways.

          1. emp. share cannot be the name of a variable as it (a) contains spaces and (b) contains a dot character.
          2. The equals sign = assigns values. You need ==
          3. drop <varname> if <expr> is "fanstasy syntax", which is clear from help drop.

          Svend gave good advice. How do you want your dataset (which is stored as a matrix) to look like?

          Best
          Daniel
          Last edited by daniel klein; 10 Oct 2014, 07:25.

          Comment


          • #6
            Code:
            replace theta=. if year==1990
            Now theta is missing for observations from year 1990

            Comment


            • #7
              Say rather that Stata's graphics ignore missing values. Here the point of weights is to change the size of the marker symbols. If you supply missing values as weights, you are in effect saying that you don't know what the sizes should be, and Stata doesn't know either.

              You need to explain more on what you want this graph to show.

              Comment


              • #8
                MaryJD,

                I'm not sure exactly what you're trying to graph but how about one of:

                1. Substitute the values for the weight variable in 1990, with those of 2000.
                2. Better than substituting, generate a copy and change whatever needs changing in 1990.
                3. Drop 1990, graph, and reload the data to keep advancing with your analysis.

                (3) is likely not necessary in your case, but I mention it just in case you think it's feasible.

                I believe you can still improve the way in which you state your problem. In fact, this is post #11, and still someone has yet to figure out what you need. For one, don't paste images of your data (see advice below); second, the image of your graph is dramatically severed; third, please read the FAQ on the preferred user naming convention: many of us encourage Statalist users to use their real full name. The latter might even help you in getting a faster/higher-quality response.

                Ultimately, if no good response comes your way, then think about overhauling your question. Invest some time and try your hardest to get the message through. Post (correctly formatted code), complete graphs (details if necessary), -list- your data, relate that listing with the graph, etc. The FAQ has general advice you should follow.
                You should:

                1. Read the FAQ carefully.

                2. "Say exactly what you typed and exactly what Stata typed (or did) in response. N.B. exactly!"

                3. Describe your dataset. Use list to list data when you are doing so. Use input to type in your own dataset fragment that others can experiment with.

                4. Use the advanced editing options to appropriately format quotes, data, code and Stata output. The advanced options can be toggled on/off using the A button in the top right corner of the text editor.

                Comment

                Working...
                X