Announcement

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

  • Using drop-command for a variable depending on the value of another variable

    Hi, for my cumulative dataset (European Social Survey 2002-2018) I have a variable which measures if a respondent is a parent or not (bthcld).
    However, for the third round of my dataset (ESS 2006), the question comes in two forms (if the respondent is a parent (bthcld)) and (if the respondent has any children living at home (chldhm)).

    To be clear, I want to keep the variable. But how can I drop the observations of the variable (bthcld) for the third round of my dataset? (essround 3) (corresponds to my time-identifier variable - essrounds).
    What I've tried to do is something in the lines of:
    Code:
     drop if bthcld == essround 3
    which creates an invalid syntax (I've included it to give an idea of what I'm trying to do).

    Kind regards










  • #2
    I do not understand the question. From the fact that "essround" can take on multiple values, I'm guessing you're creating a long data set with different rounds piled up vertically. Parent is parent, be the child living with them or not. I do not get the motive of dropping them just because they are from round 3.

    Logically, everyone would have an answer in "bthcld", if you wish to drop all the case with a valid answer in "bthcld" if they came from essround 3, then it'd just be dropping all cases from essround 3, like:

    Code:
    drop if essround == 3
    I hope this helps explaining what I am not getting.
    Last edited by Ken Chui; 17 May 2021, 06:32.

    Comment


    • #3
      You can drop an entire observation from your dataset, and you can drop an entire variable from your dataset. You cannot "drop" a variable in just a few observations, and you cannot drop part of an observation.

      The most you can hope to do is replace that variable with missing values for observations in round 3. Although I would think you would instead want to create a new variable that in rounds 1 and 2 takes its values from bthcld and in round 3 takes its values from bthcld and chldhm, so that all three rounds have a comparable variable.

      Comment


      • #4
        #3 #2
        Thanks! In that case I'm not looking to use the drop command.

        #3
        How would I go about that? Is it possible to simply use the recode command for essround 3 somehow and then code the values as missing for bthcld in that particular year?

        Comment


        • #5
          A simple recode comand solved the problem:
          Code:
          recode bthcld (1=.) (2=.) if essround==3

          Comment

          Working...
          X