The DHS Program User Forum
Discussions regarding The DHS Program data and results
Home » Topics » General » data mismatches
Re: data mismatches [message #3319 is a reply to message #3317] Thu, 20 November 2014 10:02 Go to previous messageGo to previous message
Trevor-DHS is currently offline  Trevor-DHS
Messages: 805
Registered: January 2013
Senior Member
The code I gave is for ever experienced physical violence and is used to match the data in the first column of table 15.1. I couldn't find where your numbers were coming from, but I now see that you are referring to the numbers in table 15.10 (please confirm that this is the table you are looking at), and that you are interested in spousal physical violence and not just any physical violence. Sorry, this was not clear at first.

First, I checked the code that I provided earlier and it works just fine for "ever experienced physical violence" matching table 15.1. Here is the Stata output:
. use "PHIR61FL.DTA", clear

. 
. gen PVever = (inrange(d105a, 1, 4) | inrange(d105b, 1, 4) | inrange(d105c, 1, 4) | ///
>   inrange(d105d, 1, 4) | inrange(d105e, 1, 4) | inrange(d105f, 1, 4) | ///
>   inrange(d105g, 1, 4) | inrange(d105j, 1, 4) | inrange(d130a, 1, 4) | d115y == 0 | d118y == 0)

. 
. tab PVever [iw=d005/1000000]

     PVever |      Freq.     Percent        Cum.
------------+-----------------------------------
          0 | 8,814.2297       80.40       80.40
          1 | 2,148.7701       19.60      100.00
------------+-----------------------------------
      Total |     10,963      100.00


I don't get any error message, and I can't tell from your message where the error is. Did you copy the code or re-type it? If you re-typed it, perhaps one of the variables is mis-spelled or is incorrectly upper or lower case. I would check that first.

Second, to match table 15.10 you use almost the same code, but without some of the last few conditions, however, you should limit the code to ever married women as follows:

. gen PVever_spouse = (inrange(d105a, 1, 4) | inrange(d105b, 1, 4) | inrange(d105c, 1, 4) | ///
>   inrange(d105d, 1, 4) | inrange(d105e, 1, 4) | inrange(d105f, 1, 4) | ///
>   inrange(d105g, 1, 4) | inrange(d105j, 1, 4)) if v502 > 0
(5512 missing values generated)

. 
. tab v024 PVever_spouse if v502>0 [iw=d005/1000000],row

+----------------+
| Key            |
|----------------|
|   frequency    |
| row percentage |
+----------------+

                      |     PVever_spouse
               Region |         0          1 |     Total
----------------------+----------------------+----------
National Capital Regi |987.791213 156.481776 | 1,144.273 
                      |     86.32      13.68 |    100.00 
----------------------+----------------------+----------
Cordillera Admin Regi | 99.587833  15.859699 |115.447532 
                      |     86.26      13.74 |    100.00 
----------------------+----------------------+----------
    I - Ilocos Region |291.607249  45.173311 | 336.78056 
                      |     86.59      13.41 |    100.00 
----------------------+----------------------+----------
  II - Cagayan Valley |212.098394  53.819234 |265.917628 
                      |     79.76      20.24 |    100.00 
----------------------+----------------------+----------
  III - Central Luzon |698.653727  83.820854 |782.474581 
                      |     89.29      10.71 |    100.00 
----------------------+----------------------+----------
     IVA - CALABARZON | 918.00612  99.513806 |  1,017.52 
                      |     90.22       9.78 |    100.00 
----------------------+----------------------+----------
       IVB - MIMAROPA |141.750067   30.69048 |172.440547 
                      |     82.20      17.80 |    100.00 
----------------------+----------------------+----------
            V - Bicol |305.319453  54.026097 | 359.34555 
                      |     84.97      15.03 |    100.00 
----------------------+----------------------+----------
 VI - Western Visayas |396.651668  54.116535 |450.768203 
                      |     87.99      12.01 |    100.00 
----------------------+----------------------+----------
VII - Central Visayas |425.376509  43.214089 |468.590598 
                      |     90.78       9.22 |    100.00 
----------------------+----------------------+----------
VIII - Eastern Visaya |232.304843  41.147731 |273.452574 
                      |     84.95      15.05 |    100.00 
----------------------+----------------------+----------
IX - Zamboanga Penins |265.596913  38.752526 |304.349439 
                      |     87.27      12.73 |    100.00 
----------------------+----------------------+----------
X - Northern Mindanao |273.245834  47.268561 |320.514395 
                      |     85.25      14.75 |    100.00 
----------------------+----------------------+----------
           XI - Davao |356.346056  57.555294 | 413.90135 
                      |     86.09      13.91 |    100.00 
----------------------+----------------------+----------
   XII - SOCCSKSARGEN | 287.88012   51.42066 | 339.30078 
                      |     84.85      15.15 |    100.00 
----------------------+----------------------+----------
        XIII - Caraga |168.792793  33.588978 |202.381771 
                      |     83.40      16.60 |    100.00 
----------------------+----------------------+----------
                 ARMM |206.651887   8.217312 |214.869199 
                      |     96.18       3.82 |    100.00 
----------------------+----------------------+----------
                Total | 6,267.661 914.666943 | 7,182.328 
                      |     87.27      12.73 |    100.00 
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Education, Turkey DHS
Next Topic: Education: inconsistency b/w HV and HA variables
Goto Forum:
  


Current Time: Mon Jan 27 10:52:08 Coordinated Universal Time 2025