Announcement

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

  • survey data help: dropping observations

    Hello,

    I am new to stata and would appreciate your help. I have ten crops under var2. I want to drop 8 of the crops and only analyse two of them making sure that I still have other variables like household id, sex corresponding to the two crops of interest. I can't seem to find the right drop command. The crops are listed by name eg. rice, sugar cane etc

    Thanks in advance for your help

  • #2

    Welcome to the Stata Forum / Statalist.

    You didn't provide a example we could work on. Please read the FAQ and lear how to share data/command/output.

    That being said, you wonder whether you wish something like:

    Code:
    . sysuse auto
    (1978 Automobile Data)
    
    . list make price mpg rep78 in 1/10
    
         +--------------------------------------+
         | make             price   mpg   rep78 |
         |--------------------------------------|
      1. | AMC Concord      4,099    22       3 |
      2. | AMC Pacer        4,749    17       3 |
      3. | AMC Spirit       3,799    22       . |
      4. | Buick Century    4,816    20       3 |
      5. | Buick Electra    7,827    15       4 |
         |--------------------------------------|
      6. | Buick LeSabre    5,788    18       3 |
      7. | Buick Opel       4,453    26       . |
      8. | Buick Regal      5,189    20       3 |
      9. | Buick Riviera   10,372    16       3 |
     10. | Buick Skylark    4,082    19       3 |
         +--------------------------------------+
    
    . drop if rep ==4
    (18 observations deleted)
    
    . tab rep78
    
         Repair |
    Record 1978 |      Freq.     Percent        Cum.
    ------------+-----------------------------------
              1 |          2        3.92        3.92
              2 |          8       15.69       19.61
              3 |         30       58.82       78.43
              5 |         11       21.57      100.00
    ------------+-----------------------------------
          Total |         51      100.00
    
    . list make price mpg rep78 in 1/10
    
         +--------------------------------------+
         | make             price   mpg   rep78 |
         |--------------------------------------|
      1. | AMC Concord      4,099    22       3 |
      2. | AMC Pacer        4,749    17       3 |
      3. | AMC Spirit       3,799    22       . |
      4. | Buick Century    4,816    20       3 |
      5. | Buick LeSabre    5,788    18       3 |
         |--------------------------------------|
      6. | Buick Opel       4,453    26       . |
      7. | Buick Regal      5,189    20       3 |
      8. | Buick Riviera   10,372    16       3 |
      9. | Buick Skylark    4,082    19       3 |
     10. | Cad. Deville    11,385    14       3 |
         +--------------------------------------+
    Best regards,

    Marcos

    Comment


    • #3
      On second thouhgts, I just wish to remark that:

      a) Generally speaking, we don't need to drop observations in order to perform a subgroup analysis. We just need to use the "if" clause". Another strategy is using - preserve -, then the estimation with the dropped observation, finally - restore - command.

      b) Considering you have a survey, I believe the best approach to perform the analysis of a subgroup of crops is, well, using - subgroup - within the code. This is the correct way to preserve the survey design.

      Hopefully that helps.
      Best regards,

      Marcos

      Comment


      • #4
        Thank you so much....this was helpful

        Comment

        Working...
        X