Announcement

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

  • Cases show up as missing in new var

    PLEASE DISREGARD - I made an error in coding.
    Hi.

    I am trying to generate a new var RWTEL using combinations of two other variables. (ANY and THREETELE). The problem is that RWTEL shows 2 cases as "missing" even though they take on a value in the var THREETELE, a variable I generated using Q51 and which I use to generate RWTEL.

    These two cases are coded as "13-Don't know" and "14-Other" in Q51.
    I transformed Q51 "Don't Know" and "Other" to 2 in THREETELE. But these two cases show as missing in RWTEL

    Here is my code for generating THREETELE variable:

    Code:
    Q51 -- OVERALL, for this ....
    -------------------------------------------------------------------
                          |      Freq.    Percent      Valid       Cum.
    ----------------------+--------------------------------------------
    Valid   1  None       |         12       7.89      14.46      14.46
            2  1-5%       |         34      22.37      40.96      55.42
            3  6-10%      |         15       9.87      18.07      73.49
            4  11-20%     |          7       4.61       8.43      81.93
            5  21-30%     |          3       1.97       3.61      85.54
            6  31-40%     |          1       0.66       1.20      86.75
            7  41-50%     |          2       1.32       2.41      89.16
            8  51-60%     |          2       1.32       2.41      91.57
            12 91-100%    |          5       3.29       6.02      97.59
            13 Don't Know |          1       0.66       1.20      98.80
            14 Other      |          1       0.66       1.20     100.00
            Total         |         83      54.61     100.00          
    Missing .             |         69      45.39                      
    Total                 |        152     100.00                      
    ------------------------------------------------------------------
    gen THREETELE=.
    replace THREETELE=2 if Q51==2 | Q51==3 | Q51==4 | Q51==5 | Q51==6 | Q51==7 | Q51==8 | Q51==12 | Q51==13 | Q51==14
    replace THREETELE=1 if Q51==1
    **Moved these cases from no to yes or from no to missing**
    replace THREETELE=2 if ResponseId=="R_1frer"
    replace THREETELE=2 if ResponseId=="R_3izdT"
    replace THREETELE=2 if ResponseId=="R_ZmJ"
    replaceTHREETELE=2 if ResponseId=="R_b9"
    replace THREETELE=.m if ResponseId=="R_3Hp"
    
    . tab THREETELE
    
    THREETELE
       stelecom |      Freq.     Percent        Cum.
    ------------+-----------------------------------
              1 |          7        8.54        8.54
              2 |         75       91.46      100.00
    ------------+-----------------------------------
          Total |         82      100.00
    To generate the new var RWTEL:

    Code:
    gen RWTEL=.
    replace RWTEL=1 if ANY==2 & THREETELE!=2
    replace RWTEL=2 if ANY==2 & THREETELE==2
    replace RWTEL=3 if ANY=1 & THREETELE==2
    
     tab RWTEL
    
         RWTEL |      Freq.     Percent        Cum.
    ------------+-----------------------------------
              1 |          7        8.75        8.75
              2 |         27       33.75       42.50
              3 |         46       57.50      100.00
    ------------+-----------------------------------
          Total |         80      100.00
    I checked the data browser and I see that the two observations with value label of 2 in THREETELE and 13, 14 in Q51 indicate missing in RWTEL.

    I would be very grateful for any guidance.
    Last edited by Sarah Soroui; 16 Feb 2019, 09:18.

  • #2
    Apologies - I see now what my mistake was. I had missing values in ANY var that weren't captured in the new var RWTEL.

    Code:
     
     gen RWTEL=. replace RWTEL=1 if ANY==2 & THREETELE!=2 replace RWTEL=2 if ANY==2 & THREETELE==2 replace RWTEL=3 if ANY=1 & THREETELE==2 replace RWTEL=4 if ANY==.n & THREETELE==2 replace RWTEL=4 if ANY==. & THREETELE==2  tab RWTELE       RWTELE |      Freq.     Percent        Cum. ------------+-----------------------------------           1 |          7        8.54        8.54           2 |         27       32.93       41.46           3 |         46       56.10       97.56           4 |          2        2.44      100.00 ------------+-----------------------------------       Total |         82      100.00  .

    Comment


    • #3
      Thank you for completing the thread by posting your solution to your own problem. It is likely that others will find themselves in a similar situation in the future, and now you have enabled them to find your solution if they come searching here. Sharing our Stata experiences is what this Forum is all about.

      Comment

      Working...
      X