rm(list=ls(all=t))

Setup filenames

filename <- "Section_5" # !!!Update filename
functions_vers <-  "functions_1.8.R" # !!!Update helper functions file

Setup data, functions and create dictionary for dataset review

source (functions_vers)

Visually inspect variables in "dictionary.csv" and flag for risk, using the following flags:

# Direct PII: Respondent Names, Addresses, Identification Numbers, Phone Numbers
# Direct PII-team: Interviewer Names, other field team names 
# Indirect PII-ordinal: Date of birth, Age, income, education, household composition. 
# Indirect PII-categorical: Gender, education, ethnicity, nationality,
# occupation, employer, head of household, marital status
# GPS: Longitude, Latitude
# Small Location: Location (<100,000) 
# Large Location (>100,000)
# Weight: weightVar
# Household ID:  hhId, 
# Open-ends: Review responses for any sensitive information, redact as necessary 

Direct PII: variables to be removed

# !!!No Direct PII

Direct PII-team: Encode field team names

# !!!No Direct PII-team

Small locations: Encode locations with pop <100,000 using random large numbers

# !!!No small locations

Indirect PII - Ordinal: Global recode or Top/bottom coding for extreme values

# Focus on variables with a "Lowest Freq" in dictionary of 30 or less. 

mydata <- top_recode ("s5q1", break_point=3, missing=c(888, 999999))
## [1] "Frequency table before encoding"
## s5q1. How many houses does your household own?  Ilang bahay ang pag-aari ng iyong kasa
##    0    1    2    3    4 <NA> 
##  274 1979   40    1    1    1

## [1] "Frequency table after encoding"
## s5q1. How many houses does your household own?  Ilang bahay ang pag-aari ng iyong kasa
##         0         1         2 3 or more      <NA> 
##       274      1979        40         2         1

mydata <- top_recode ("s5q3", break_point=1, missing=c(888, 999999))
## [1] "Frequency table before encoding"
## s5q3. How many landline/wireless telephones does your household own?  Ilang telepono/w
##    0    1    8 <NA> 
## 2290    4    1    1

## [1] "Frequency table after encoding"
## s5q3. How many landline/wireless telephones does your household own?  Ilang telepono/w
##         0 1 or more      <NA> 
##      2290         5         1

mydata <- top_recode ("s5q5", break_point=6, missing=c(888, 999999))
## [1] "Frequency table before encoding"
## s5q5. How many  cell phones does your household own?  Ilang cell phone ang pag mamay-a
##    0    1    2    3    4    5    6    7    8    9   10   12 <NA> 
##  210  830  653  348  144   64   29    8    5    1    1    2    1

## [1] "Frequency table after encoding"
## s5q5. How many  cell phones does your household own?  Ilang cell phone ang pag mamay-a
##         0         1         2         3         4         5 6 or more      <NA> 
##       210       830       653       348       144        64        46         1

mydata <- top_recode ("s5q7", break_point=4, missing=c(888, 999999))
## [1] "Frequency table before encoding"
## s5q7. How many  sofas does your household own?  Ilang sofa ang pag mamay-ari ng iyong 
##    0    1    2    3    4    5 <NA> 
## 1619  558   69   38    8    3    1

## [1] "Frequency table after encoding"
## s5q7. How many  sofas does your household own?  Ilang sofa ang pag mamay-ari ng iyong 
##         0         1         2         3 4 or more      <NA> 
##      1619       558        69        38        11         1

mydata <- top_recode ("s5q9", break_point=9, missing=c(888, 999999))
## [1] "Frequency table before encoding"
## s5q9. How many chairs does your household own?  Ilang upuan ang pag mamay-ari ng iyong
##    0    1    2    3    4    5    6    7    8    9   10   11   12   13   14   16   20 <NA> 
##  533  275  408  355  290  146  158   39   39   10   23    5   10    1    1    1    1    1

## [1] "Frequency table after encoding"
## s5q9. How many chairs does your household own?  Ilang upuan ang pag mamay-ari ng iyong
##         0         1         2         3         4         5         6         7         8 9 or more      <NA> 
##       533       275       408       355       290       146       158        39        39        52         1

mydata <- top_recode ("s5q11", break_point=4, missing=c(888, 999999))
## [1] "Frequency table before encoding"
## s5q11. How many tables does your household own?  Ilang lamesa ang pag mamay-ari ng iyon
##    0    1    2    3    4    5    6    7    8   13 <NA> 
##  379 1331  449   99   29    4    1    1    1    1    1

## [1] "Frequency table after encoding"
## s5q11. How many tables does your household own?  Ilang lamesa ang pag mamay-ari ng iyon
##         0         1         2         3 4 or more      <NA> 
##       379      1331       449        99        37         1

mydata <- top_recode ("s5q13", break_point=4, missing=c(888, 999999))
## [1] "Frequency table before encoding"
## s5q13. How many clocks/watches does your household own?  Ilang orasan/relos ang pag mam
##    0    1    2    3    4    5    6    7    8    9 <NA> 
## 1167  916  141   44   16    4    3    1    2    1    1

## [1] "Frequency table after encoding"
## s5q13. How many clocks/watches does your household own?  Ilang orasan/relos ang pag mam
##         0         1         2         3 4 or more      <NA> 
##      1167       916       141        44        27         1

mydata <- top_recode ("s5q15", break_point=3, missing=c(888, 999999))
## [1] "Frequency table before encoding"
## s5q15. How many bicycles does your household own?  Ilang bisikleta ang pag mamay-ari ng
##    0    1    2    3    4    5    9 <NA> 
## 1754  464   58   13    4    1    1    1

## [1] "Frequency table after encoding"
## s5q15. How many bicycles does your household own?  Ilang bisikleta ang pag mamay-ari ng
##         0         1         2 3 or more      <NA> 
##      1754       464        58        19         1

mydata <- top_recode ("s5q17", break_point=2, missing=c(888, 999999))
## [1] "Frequency table before encoding"
## s5q17. How many tricycles does your household own?  Ilang traysikel ang pag mamay-ari n
##    0    1    2    4    5 <NA> 
## 2141  149    3    1    1    1

## [1] "Frequency table after encoding"
## s5q17. How many tricycles does your household own?  Ilang traysikel ang pag mamay-ari n
##         0         1 2 or more      <NA> 
##      2141       149         5         1

mydata <- top_recode ("s5q19", break_point=2, missing=c(888, 999999))
## [1] "Frequency table before encoding"
## s5q19. How many motorbikes does your household own?  Ilang motorsiklo ang pag mamay-ari
##    0    1    2    3    4    8 <NA> 
## 1878  386   27    1    2    1    1

## [1] "Frequency table after encoding"
## s5q19. How many motorbikes does your household own?  Ilang motorsiklo ang pag mamay-ari
##         0         1 2 or more      <NA> 
##      1878       386        31         1

mydata <- top_recode ("s5q21", break_point=2, missing=c(888, 999999))
## [1] "Frequency table before encoding"
## s5q21. How many motorized boats/bancas does your household own?  Ilang bangkang de-moto
##    0    1    2 <NA> 
## 2178  108    9    1

## [1] "Frequency table after encoding"
## s5q21. How many motorized boats/bancas does your household own?  Ilang bangkang de-moto
##         0         1 2 or more      <NA> 
##      2178       108         9         1

mydata <- top_recode ("s5q23", break_point=1, missing=c(888, 999999))
## [1] "Frequency table before encoding"
## s5q23. How many other motorized vehicles does your household own?  Ilang sasakyang de-m
##    0    1    8 <NA> 
## 2273   21    1    1

## [1] "Frequency table after encoding"
## s5q23. How many other motorized vehicles does your household own?  Ilang sasakyang de-m
##         0 1 or more      <NA> 
##      2273        22         1

mydata <- top_recode ("s5q25", break_point=3, missing=c(888, 999999))
## [1] "Frequency table before encoding"
## s5q25. How many radio, tape, or CD players does your household own?  Ilang radyo, teyp 
##    0    1    2    3    5    7    8 <NA> 
## 1320  914   52    6    1    1    1    1

## [1] "Frequency table after encoding"
## s5q25. How many radio, tape, or CD players does your household own?  Ilang radyo, teyp 
##         0         1         2 3 or more      <NA> 
##      1320       914        52         9         1

mydata <- top_recode ("s5q27", break_point=4, missing=c(888, 999999))
## [1] "Frequency table before encoding"
## s5q27. How many beds does your household own?  Ilang kama ang pag mamay-ari ng iyong ka
##    0    1    2    3    4    5    8 <NA> 
## 1342  542  305   84   19    2    1    1

## [1] "Frequency table after encoding"
## s5q27. How many beds does your household own?  Ilang kama ang pag mamay-ari ng iyong ka
##         0         1         2         3 4 or more      <NA> 
##      1342       542       305        84        22         1

mydata <- top_recode ("s5q29", break_point=4, missing=c(888, 999999))
## [1] "Frequency table before encoding"
## s5q29. How many mattresses does your household own?  Ilang kutson ang pag mamay-ari ng 
##    0    1    2    3    4    5    6    8 <NA> 
## 1316  684  229   53   10    1    1    1    1

## [1] "Frequency table after encoding"
## s5q29. How many mattresses does your household own?  Ilang kutson ang pag mamay-ari ng 
##         0         1         2         3 4 or more      <NA> 
##      1316       684       229        53        13         1

mydata <- top_recode ("s5q33", break_point=1, missing=c(888, 999999))
## [1] "Frequency table before encoding"
## s5q33. How many generators does your household own?  Ilang generator ang pag mamay-ari 
##    0    1    8 <NA> 
## 2287    5    3    1

## [1] "Frequency table after encoding"
## s5q33. How many generators does your household own?  Ilang generator ang pag mamay-ari 
##         0 1 or more      <NA> 
##      2287         8         1

mydata <- top_recode ("s5q35", break_point=3, missing=c(888, 999999))
## [1] "Frequency table before encoding"
## s5q35. How many televisions does your household own?  Ilang telebisyon ang pag mamay-ar
##    0    1    2    3    4 <NA> 
##  598 1624   68    4    1    1

## [1] "Frequency table after encoding"
## s5q35. How many televisions does your household own?  Ilang telebisyon ang pag mamay-ar
##         0         1         2 3 or more      <NA> 
##       598      1624        68         5         1

mydata <- top_recode ("s5q37", break_point=3, missing=c(888, 999999))
## [1] "Frequency table before encoding"
## s5q37. How many VCRs/DVD players does your household own?  Ilang VCRs/pangtugtog ng DVD
##    0    1    2    3    8 <NA> 
## 1550  701   39    3    2    1

## [1] "Frequency table after encoding"
## s5q37. How many VCRs/DVD players does your household own?  Ilang VCRs/pangtugtog ng DVD
##         0         1         2 3 or more      <NA> 
##      1550       701        39         5         1

mydata <- top_recode ("s5q39", break_point=2, missing=c(888, 999999))
## [1] "Frequency table before encoding"
## s5q39. How many computers does your household own?  Ilang kompyuter ang pag mamay-ari n
##    0    1    2    8 <NA> 
## 2236   51    4    4    1

## [1] "Frequency table after encoding"
## s5q39. How many computers does your household own?  Ilang kompyuter ang pag mamay-ari n
##         0         1 2 or more      <NA> 
##      2236        51         8         1

mydata <- top_recode ("s5q41", break_point=6, missing=c(888, 999999))
## [1] "Frequency table before encoding"
## s5q41. How many farm tools does your household own?  Ilang kagamitang pansaka ang pag m
##    0    1    2    3    4    5    6    7    8    9   10   12   14   15 <NA> 
## 1636  248  136  109   69   44   24    7    8    6    5    1    1    1    1

## [1] "Frequency table after encoding"
## s5q41. How many farm tools does your household own?  Ilang kagamitang pansaka ang pag m
##         0         1         2         3         4         5 6 or more      <NA> 
##      1636       248       136       109        69        44        53         1

mydata <- top_recode ("s5q43", break_point=1, missing=c(888, 999999))
## [1] "Frequency table before encoding"
## s5q43. How many wheelbarrows does your household own?  Ilang kartilya ang pag mamay-ari
##    0    1    2    3 <NA> 
## 2266   26    2    1    1

## [1] "Frequency table after encoding"
## s5q43. How many wheelbarrows does your household own?  Ilang kartilya ang pag mamay-ari
##         0 1 or more      <NA> 
##      2266        29         1

mydata <- top_recode ("s5q45", break_point=2, missing=c(888, 999999))
## [1] "Frequency table before encoding"
## s5q45. How many carts does your household own?  Ilang kariton ang pag mamay-ari ng iyon
##    0    1    2    3    8 <NA> 
## 2193   97    3    1    1    1

## [1] "Frequency table after encoding"
## s5q45. How many carts does your household own?  Ilang kariton ang pag mamay-ari ng iyon
##         0         1 2 or more      <NA> 
##      2193        97         5         1

mydata <- top_recode ("s5q47", break_point=2, missing=c(888, 999999))
## [1] "Frequency table before encoding"
## s5q47. How many kerosene or propane stoves does your household own?  Ilang kalang de-pe
##    0    1    2    3    8 <NA> 
## 2029  258    5    2    1    1

## [1] "Frequency table after encoding"
## s5q47. How many kerosene or propane stoves does your household own?  Ilang kalang de-pe
##         0         1 2 or more      <NA> 
##      2029       258         8         1

mydata <- top_recode ("s5q49", break_point=2, missing=c(888, 999999))
## [1] "Frequency table before encoding"
## s5q49. How many stoves with oven/gas ranges does your household own?  Ilang kalang mayr
##    0    1    2    8 <NA> 
## 2014  273    7    1    1

## [1] "Frequency table after encoding"
## s5q49. How many stoves with oven/gas ranges does your household own?  Ilang kalang mayr
##         0         1 2 or more      <NA> 
##      2014       273         8         1

mydata <- top_recode ("s5q51", break_point=2, missing=c(888, 999999))
## [1] "Frequency table before encoding"
## s5q51. How many refrigerators does your household own?  Ilang refigerator ang pag mamay
##    0    1    2   19 <NA> 
## 2012  276    6    1    1

## [1] "Frequency table after encoding"
## s5q51. How many refrigerators does your household own?  Ilang refigerator ang pag mamay
##         0         1 2 or more      <NA> 
##      2012       276         7         1

mydata <- top_recode ("s5q53", break_point=2, missing=c(888, 999999))
## [1] "Frequency table before encoding"
## s5q53. How many clothes washing machines does your household own?  Ilang washing machin
##    0    1    2    4    8 <NA> 
## 1850  436    5    1    3    1

## [1] "Frequency table after encoding"
## s5q53. How many clothes washing machines does your household own?  Ilang washing machin
##         0         1 2 or more      <NA> 
##      1850       436         9         1

mydata <- top_recode ("s5q55", break_point=1, missing=c(888, 999999))
## [1] "Frequency table before encoding"
## s5q55. How many  air conditioners does your household own?  Ilang aircon ang pag mamay-
##    0    1 <NA> 
## 2292    3    1

## [1] "Frequency table after encoding"
## s5q55. How many  air conditioners does your household own?  Ilang aircon ang pag mamay-
##         0 1 or more      <NA> 
##      2292         3         1

mydata <- top_recode ("s5q56a", break_point=4, missing=c(888, 999999))
## [1] "Frequency table before encoding"
## s5q56a. How many electric fans does your household own?  Ilang bentilador ang pag mamay-
##    0    1    2    3    4    5 <NA> 
##  809 1011  404   56    9    6    1

## [1] "Frequency table after encoding"
## s5q56a. How many electric fans does your household own?  Ilang bentilador ang pag mamay-
##         0         1         2         3 4 or more      <NA> 
##       809      1011       404        56        15         1

mydata <- top_recode ("s5q56fishnet", break_point=2, missing=c(888, 999999))
## [1] "Frequency table before encoding"
## s5q56fishnet. How many fishing nets does your household own?  Ilang lambat ang pagmamay-ari ng
##    0    1    2    3    4    5    6    8   10   12   13   15   17   18   20   21   22   25   26   28   29 <NA> 
## 2060  132   27   17    5    7    5    4   13    4    2    3    1    2    6    1    1    1    1    1    1    2

## [1] "Frequency table after encoding"
## s5q56fishnet. How many fishing nets does your household own?  Ilang lambat ang pagmamay-ari ng
##         0         1 2 or more      <NA> 
##      2060       132       102         2

mydata <- top_recode ("s5q56pedicab", break_point=2, missing=c(888, 999999))
## [1] "Frequency table before encoding"
## s5q56pedicab. How many pedicabs does your household own?  Ilang pedicabs ang pagmamay-ari ng i
##    0    1    2    3    8 <NA> 
## 2207   80    4    3    1    1

## [1] "Frequency table after encoding"
## s5q56pedicab. How many pedicabs does your household own?  Ilang pedicabs ang pagmamay-ari ng i
##         0         1 2 or more      <NA> 
##      2207        80         8         1

mydata <- top_recode ("s5q56ricestock", break_point=4, missing=c(888, 999999))
## [1] "Frequency table before encoding"
## s5q56ricestock. How many rice stocks does your household own?  Ilang ipon na bigas ang pagmamay-
##    0    1    2    3    4    5    6    7    8    9   10   11   12   13   14   15   16   17   18   19   20   21 
## 1804  129   68   41   15   58    9    6    9    4   57    1    8    3    1   10    1    1    4    2   16    1 
##   25   27   28 <NA> 
##   42    1    1    4

## [1] "Frequency table after encoding"
## s5q56ricestock. How many rice stocks does your household own?  Ilang ipon na bigas ang pagmamay-
##         0         1         2         3 4 or more      <NA> 
##      1804       129        68        41       250         4

# Top code high values to the 99.5 percentile

percentile_99.5 <- floor(quantile(na.exclude(mydata$s5q2)[na.exclude(mydata$s5q2)!=999999], probs = c(0.995)))
mydata <- top_recode (variable="s5q2", break_point=percentile_99.5, missing=999999)
## [1] "Frequency table before encoding"
## s5q2. What is the total value of this/these houses ?  Magkano ang kabuuang halaga ng/n
##       0      20      25      30      35      70      80     100     110     120     150     200     300 
##     277       1       2       3       1       1       1       2       1       1       2       4       2 
##     500     700    1000    1500    2000    2500    2900    3000    3500    4000    4500    5000    6000 
##      10       1      15      11      38       6       1      39       2      10       1     138      20 
##    6500    7000    8000    9000   10000   11000   12000   13000   14000   14500   15000   16000   16500 
##       1      18      13       6     231       3      12       1       5       1     106       3       1 
##   17000   18000   19500   20000   25000   27000   29000   30000   35000   36000   40000   45000   48000 
##       3       6       1     193      33       1       1     136      19       2      55       8       1 
##   50000   53000   55000   56000   57000   58000   60000   62000   65000   70000   73000   75000   80000 
##     230       1       3       1       1       1      34       1       1      36       1       6      47 
##   85000   90000   92800   95000   1e+05  105000  110000  115000  118000  120000  125000  126000  130000 
##       2       2       1       1     154       1       6       1       1      10       2       1       4 
##  150000  155000  165000  190000   2e+05  250000  270000   3e+05   4e+05  450000   5e+05  550000  650000 
##      54       1       1       1      58      14       1      22       7       2      19       1       1 
##   7e+05   8e+05   1e+06   2e+06 2500000   4e+06   1e+07 1.5e+07    <NA> 
##       3       3       5       1       1       1       1       1      99

## [1] "Frequency table after encoding"
## s5q2. What is the total value of this/these houses ?  Magkano ang kabuuang halaga ng/n
##             0            20            25            30            35            70            80 
##           277             1             2             3             1             1             1 
##           100           110           120           150           200           300           500 
##             2             1             1             2             4             2            10 
##           700          1000          1500          2000          2500          2900          3000 
##             1            15            11            38             6             1            39 
##          3500          4000          4500          5000          6000          6500          7000 
##             2            10             1           138            20             1            18 
##          8000          9000         10000         11000         12000         13000         14000 
##            13             6           231             3            12             1             5 
##         14500         15000         16000         16500         17000         18000         19500 
##             1           106             3             1             3             6             1 
##         20000         25000         27000         29000         30000         35000         36000 
##           193            33             1             1           136            19             2 
##         40000         45000         48000         50000         53000         55000         56000 
##            55             8             1           230             1             3             1 
##         57000         58000         60000         62000         65000         70000         73000 
##             1             1            34             1             1            36             1 
##         75000         80000         85000         90000         92800         95000         1e+05 
##             6            47             2             2             1             1           154 
##        105000        110000        115000        118000        120000        125000        126000 
##             1             6             1             1            10             2             1 
##        130000        150000        155000        165000        190000         2e+05        250000 
##             4            54             1             1             1            58            14 
##        270000         3e+05         4e+05        450000         5e+05        550000        650000 
##             1            22             7             2            19             1             1 
##         7e+05 8e+05 or more          <NA> 
##             3            13            99

percentile_99.5 <- floor(quantile(na.exclude(mydata$s5q4)[na.exclude(mydata$s5q4)!=999999], probs = c(0.995)))
mydata <- top_recode (variable="s5q4", break_point=percentile_99.5, missing=999999)
## [1] "Frequency table before encoding"
## s5q4. What is the total value of the landline/wireless telephone?  Magkano ang kabuuan
##     0     8   300  1500 20000  <NA> 
##  2285     3     1     1     1     5

## [1] "Frequency table after encoding"
## s5q4. What is the total value of the landline/wireless telephone?  Magkano ang kabuuan
## 0 or more      <NA> 
##      2291         5

percentile_99.5 <- floor(quantile(na.exclude(mydata$s5q6)[na.exclude(mydata$s5q6)!=999999], probs = c(0.995)))
mydata <- top_recode (variable="s5q6", break_point=percentile_99.5, missing=999999)
## [1] "Frequency table before encoding"
## s5q6. What is the total value of these cell phones ?  Magkano ang kabuuang halaga ng m
##     0    50    60   100   150   200   250   300   350   370   380   399   400   450   458   495   499   500 
##   230     4     1    14     7    54     9    81     3     1     1     9    44     5     1     2     9   271 
##   550   599   600   650   700   710   750   760   790   800   850   899   900   950   999  1000  1050  1099 
##     4     1    61     2    49     1     3     1     1    53     2     1    26     1     1   239     3     1 
##  1100  1180  1199  1200  1250  1299  1300  1350  1400  1497  1500  1600  1700  1800  1898  1900  1999  2000 
##    15     1     1    52     3     2    11     1    19     1   143    10     8    18     1    12     1   143 
##  2100  2200  2250  2300  2400  2500  2600  2650  2700  2800  2900  2966  3000  3100  3200  3300  3345  3350 
##     5     8     1     8    10    47     1     1     7     8     5     1   103     1     9     4     1     1 
##  3400  3500  3600  3700  3800  3900  3990  4000  4100  4200  4300  4390  4400  4500  4600  4700  4800  5000 
##     4    23     4     3     1     3     1    56     2     3     3     1     2    14     2     2     2    53 
##  5200  5300  5499  5500  5800  6000  6050  6200  6500  6700  7000  7300  7500  7800  7998  8000  8400  8500 
##     1     2     1     8     1    28     1     3     3     1    22     1     4     1     1    12     1     2 
##  8700  9000  9300  9500 10000 10200 10300 10400 10500 10600 10800 11000 11800 12000 12300 15000 16000 17000 
##     1     2     1     2    22     1     1     1     2     1     1     1     1     7     1     8     1     1 
## 20000 25000 26000 28000 30000 40000 50000  <NA> 
##     7     1     1     1     1     1     1    97

## [1] "Frequency table after encoding"
## s5q6. What is the total value of these cell phones ?  Magkano ang kabuuang halaga ng m
##             0            50            60           100           150           200           250 
##           230             4             1            14             7            54             9 
##           300           350           370           380           399           400           450 
##            81             3             1             1             9            44             5 
##           458           495           499           500           550           599           600 
##             1             2             9           271             4             1            61 
##           650           700           710           750           760           790           800 
##             2            49             1             3             1             1            53 
##           850           899           900           950           999          1000          1050 
##             2             1            26             1             1           239             3 
##          1099          1100          1180          1199          1200          1250          1299 
##             1            15             1             1            52             3             2 
##          1300          1350          1400          1497          1500          1600          1700 
##            11             1            19             1           143            10             8 
##          1800          1898          1900          1999          2000          2100          2200 
##            18             1            12             1           143             5             8 
##          2250          2300          2400          2500          2600          2650          2700 
##             1             8            10            47             1             1             7 
##          2800          2900          2966          3000          3100          3200          3300 
##             8             5             1           103             1             9             4 
##          3345          3350          3400          3500          3600          3700          3800 
##             1             1             4            23             4             3             1 
##          3900          3990          4000          4100          4200          4300          4390 
##             3             1            56             2             3             3             1 
##          4400          4500          4600          4700          4800          5000          5200 
##             2            14             2             2             2            53             1 
##          5300          5499          5500          5800          6000          6050          6200 
##             2             1             8             1            28             1             3 
##          6500          6700          7000          7300          7500          7800          7998 
##             3             1            22             1             4             1             1 
##          8000          8400          8500          8700          9000          9300          9500 
##            12             1             2             1             2             1             2 
##         10000         10200         10300         10400         10500         10600         10800 
##            22             1             1             1             2             1             1 
##         11000         11800         12000         12300         15000         16000         17000 
##             1             1             7             1             8             1             1 
## 20000 or more          <NA> 
##            13            97

percentile_99.5 <- floor(quantile(na.exclude(mydata$s5q8)[na.exclude(mydata$s5q8)!=999999], probs = c(0.995)))
mydata <- top_recode (variable="s5q8", break_point=percentile_99.5, missing=999999)
## [1] "Frequency table before encoding"
## s5q8. What is the total value of sofas ?  Magkano ang kabuuang halaga ng mga sofa?
##     0     8    20    30    40    50   100   150   200   210   250   300   350   400   470   500   600   700 
##  1633     4     3     1     3    13    25     6    29     1     2    35     1    10     1    85     5    17 
##   750   800   900  1000  1050  1100  1200  1300  1500  1600  1700  1800  2000  2100  2200  2300  2400  2500 
##     3     7     3    74     1     1    17     4    39     1     4     7    50     1     5     2     3    24 
##  2600  2700  2800  3000  3100  3200  3450  3500  3800  4000  4500  5000  5800  6000  6600  7000  8000 10000 
##     1     2     3    31     1     1     1     9     2     8     4    20     1     7     1     9     4     7 
## 11000 11500 12000 15000 18000 20000  <NA> 
##     2     1     3     5     1     2    50

## [1] "Frequency table after encoding"
## s5q8. What is the total value of sofas ?  Magkano ang kabuuang halaga ng mga sofa?
##             0             8            20            30            40            50           100 
##          1633             4             3             1             3            13            25 
##           150           200           210           250           300           350           400 
##             6            29             1             2            35             1            10 
##           470           500           600           700           750           800           900 
##             1            85             5            17             3             7             3 
##          1000          1050          1100          1200          1300          1500          1600 
##            74             1             1            17             4            39             1 
##          1700          1800          2000          2100          2200          2300          2400 
##             4             7            50             1             5             2             3 
##          2500          2600          2700          2800          3000          3100          3200 
##            24             1             2             3            31             1             1 
##          3450          3500          3800          4000          4500          5000          5800 
##             1             9             2             8             4            20             1 
##          6000          6600          7000          8000         10000         11000 11387 or more 
##             7             1             9             4             7             2            12 
##          <NA> 
##            50

percentile_99.5 <- floor(quantile(na.exclude(mydata$s5q10)[na.exclude(mydata$s5q10)!=999999], probs = c(0.995)))
mydata <- top_recode (variable="s5q10", break_point=percentile_99.5, missing=999999)
## [1] "Frequency table before encoding"
## s5q10. What is the total value of the chairs ?  Magkano ang kabuuang halaga ng (mga) up
##     0     1     2     4     5     7     8    10    15    20    25    30    40    48    50    60    70    80 
##   578     3     1     1     2     1     1    13     1    21     2    10    12     1    96    13     2     6 
##    90   100   110   120   125   130   135   140   150   160   170   180   200   210   220   236   240   250 
##     6   157     1     4     1     1     1     2    70     2     1     3   131     2     2     1     3    21 
##   270   276   300   320   338   350   360   375   390   400   440   450   480   500   508   525   540   550 
##     1     1   133     1     1     8     5     2     1    56     1    26     4   129     2     1     6     2 
##   560   570   580   600   630   640   660   690   700   710   720   750   780   800   855   875   900   920 
##     1     1     1    73     1     5     3     1    24     1     2    23     1    39     1     1    19     1 
##   930   960  1000  1050  1080  1090  1100  1140  1150  1155  1200  1250  1300  1320  1350  1400  1440  1500 
##     1     2   108     3     2     1     2     1     2     1    20     8     3     1     3     3     1    73 
##  1505  1550  1600  1620  1623  1650  1700  1750  1780  1800  1875  1900  1950  1980  2000  2100  2200  2400 
##     1     1     4     2     1     1     5     1     1    13     1     3     1     1    41     6     3     3 
##  2500  2600  2640  2700  2730  2800  2900  3000  3200  3250  3500  3550  3600  3700  3800  4000  4400  4450 
##    19     2     1     7     1     7     2    26     1     1     8     1     1     1     2     7     1     1 
##  4500  4700  5000  5040  5150  5200  6200  7000  7500  9700 10000 11000 12000 12500 19680 28000  <NA> 
##     2     1    12     1     1     1     1     4     1     1     2     1     1     1     1     1   100

## [1] "Frequency table after encoding"
## s5q10. What is the total value of the chairs ?  Magkano ang kabuuang halaga ng (mga) up
##            0            1            2            4            5            7            8           10 
##          578            3            1            1            2            1            1           13 
##           15           20           25           30           40           48           50           60 
##            1           21            2           10           12            1           96           13 
##           70           80           90          100          110          120          125          130 
##            2            6            6          157            1            4            1            1 
##          135          140          150          160          170          180          200          210 
##            1            2           70            2            1            3          131            2 
##          220          236          240          250          270          276          300          320 
##            2            1            3           21            1            1          133            1 
##          338          350          360          375          390          400          440          450 
##            1            8            5            2            1           56            1           26 
##          480          500          508          525          540          550          560          570 
##            4          129            2            1            6            2            1            1 
##          580          600          630          640          660          690          700          710 
##            1           73            1            5            3            1           24            1 
##          720          750          780          800          855          875          900          920 
##            2           23            1           39            1            1           19            1 
##          930          960         1000         1050         1080         1090         1100         1140 
##            1            2          108            3            2            1            2            1 
##         1150         1155         1200         1250         1300         1320         1350         1400 
##            2            1           20            8            3            1            3            3 
##         1440         1500         1505         1550         1600         1620         1623         1650 
##            1           73            1            1            4            2            1            1 
##         1700         1750         1780         1800         1875         1900         1950         1980 
##            5            1            1           13            1            3            1            1 
##         2000         2100         2200         2400         2500         2600         2640         2700 
##           41            6            3            3           19            2            1            7 
##         2730         2800         2900         3000         3200         3250         3500         3550 
##            1            7            2           26            1            1            8            1 
##         3600         3700         3800         4000         4400         4450         4500         4700 
##            1            1            2            7            1            1            2            1 
##         5000         5040         5150         5200         6200 7000 or more         <NA> 
##           12            1            1            1            1           13          100

percentile_99.5 <- floor(quantile(na.exclude(mydata$s5q12)[na.exclude(mydata$s5q12)!=999999], probs = c(0.995)))
mydata <- top_recode (variable="s5q12", break_point=percentile_99.5, missing=999999)
## [1] "Frequency table before encoding"
## s5q12. What is the total value of these tables?  Magkano ang kabuuang halaga ng (mga) l
##     0    10    15    20    25    30    35    40    50    60    70    75    80   100   108   120   135   150 
##   458     4     1    34     2    12     1     4   122     3     2     1     1   226     1     1     1    69 
##   200   240   250   300   350   400   450   500   570   600   640   700   750   800   850   900   950  1000 
##   211     1    27   153    21    53     8   267     2    50     1    50    14    25     2    12     3   115 
##  1100  1150  1200  1300  1350  1400  1495  1500  1550  1600  1650  1700  1800  1900  1950  2000  2100  2200 
##     3     1    15     4     1     4     1    56     1     5     1     1     2     1     1    20     3     2 
##  2400  2500  2700  2800  3000  3100  3300  3500  4000  4500  4800  5000  5050  6000  7000  8000  8100  8300 
##     1    11     1     1    20     1     1     4    10     1     1    11     1     3     2     1     1     1 
##  9000 10000 15000  <NA> 
##     1     7     1   135

## [1] "Frequency table after encoding"
## s5q12. What is the total value of these tables?  Magkano ang kabuuang halaga ng (mga) l
##            0           10           15           20           25           30           35           40 
##          458            4            1           34            2           12            1            4 
##           50           60           70           75           80          100          108          120 
##          122            3            2            1            1          226            1            1 
##          135          150          200          240          250          300          350          400 
##            1           69          211            1           27          153           21           53 
##          450          500          570          600          640          700          750          800 
##            8          267            2           50            1           50           14           25 
##          850          900          950         1000         1100         1150         1200         1300 
##            2           12            3          115            3            1           15            4 
##         1350         1400         1495         1500         1550         1600         1650         1700 
##            1            4            1           56            1            5            1            1 
##         1800         1900         1950         2000         2100         2200         2400         2500 
##            2            1            1           20            3            2            1           11 
##         2700         2800         3000         3100         3300         3500         4000         4500 
##            1            1           20            1            1            4           10            1 
##         4800         5000         5050         6000         7000         8000 8019 or more         <NA> 
##            1           11            1            3            2            1           11          135

percentile_99.5 <- floor(quantile(na.exclude(mydata$s5q14)[na.exclude(mydata$s5q14)!=999999], probs = c(0.995)))
mydata <- top_recode (variable="s5q14", break_point=percentile_99.5, missing=999999)
## [1] "Frequency table before encoding"
## s5q14. What is the total value of these clock/watch ?  Magkano ang kabuuang halaga ng (
##     0     1     2     5     8    10    15    20    25    30    35    40    45    50    55    60    65    70 
##  1180     3     1     5     2     6     1    21     1    13     8     2     5   132     2    17    10     8 
##    75    80    85    89    90    95    99   100   103   108   110   118   119   120   125   130   138   140 
##    31    15     7     1     5     3     2   220     1     1     4     1     1    31     2     4     1     4 
##   150   159   160   170   175   179   180   185   190   200   210   220   225   230   240   250   260   300 
##   165     1     4     1     2     1     9     1     2    72     1     2     1     2     3    24     1    47 
##   308   330   350   360   400   440   450   470   500   550   565   600   700   750   800   820   900   996 
##     1     1    15     1     7     1     3     1    33     2     1     7     7     1     4     1     1     1 
##  1000  1100  1150  1200  1500  1550  1600  1800  2000  2100  2500  2800  3000  3200  3600  3700  4000  5000 
##    23     2     1     2     6     1     1     1     8     1     4     1     5     1     1     2     1     1 
##  5100 14300  <NA> 
##     1     1    54

## [1] "Frequency table after encoding"
## s5q14. What is the total value of these clock/watch ?  Magkano ang kabuuang halaga ng (
##            0            1            2            5            8           10           15           20 
##         1180            3            1            5            2            6            1           21 
##           25           30           35           40           45           50           55           60 
##            1           13            8            2            5          132            2           17 
##           65           70           75           80           85           89           90           95 
##           10            8           31           15            7            1            5            3 
##           99          100          103          108          110          118          119          120 
##            2          220            1            1            4            1            1           31 
##          125          130          138          140          150          159          160          170 
##            2            4            1            4          165            1            4            1 
##          175          179          180          185          190          200          210          220 
##            2            1            9            1            2           72            1            2 
##          225          230          240          250          260          300          308          330 
##            1            2            3           24            1           47            1            1 
##          350          360          400          440          450          470          500          550 
##           15            1            7            1            3            1           33            2 
##          565          600          700          750          800          820          900          996 
##            1            7            7            1            4            1            1            1 
##         1000         1100         1150         1200         1500         1550         1600         1800 
##           23            2            1            2            6            1            1            1 
##         2000         2100         2500         2800 3000 or more         <NA> 
##            8            1            4            1           13           54

percentile_99.5 <- floor(quantile(na.exclude(mydata$s5q16)[na.exclude(mydata$s5q16)!=999999], probs = c(0.995)))
mydata <- top_recode (variable="s5q16", break_point=percentile_99.5, missing=999999)
## [1] "Frequency table before encoding"
## s5q16. What is the total value of these bicycles ?  Magkano ang kabuuang halaga ng (mga
##     0     3     8    15    20    30    50   100   108   150   200   250   300   350   400   450   500   600 
##  1755     1     1     1     1     1     8     7     1     2    12     2    25     3     5     1    71     6 
##   700   750   800   850   900  1000  1100  1200  1250  1300  1400  1500  1600  1700  1800  1900  2000  2100 
##    12     1    14     1     1    71     1    14     1     7     1    62     1     9    12     1    33     3 
##  2200  2300  2400  2500  2600  2700  2800  3000  3150  3200  3500  3600  4000  4100  4200  4500  4700  5000 
##     4     5     5    26     2     4     6    29     1     1     7     2     3     1     2     4     2     5 
##  5500  6000  6800  7000 10000 17000 18000 20000 32000 50000  <NA> 
##     1     3     1     3     2     1     1     1     1     1    24

## [1] "Frequency table after encoding"
## s5q16. What is the total value of these bicycles ?  Magkano ang kabuuang halaga ng (mga
##            0            3            8           15           20           30           50          100 
##         1755            1            1            1            1            1            8            7 
##          108          150          200          250          300          350          400          450 
##            1            2           12            2           25            3            5            1 
##          500          600          700          750          800          850          900         1000 
##           71            6           12            1           14            1            1           71 
##         1100         1200         1250         1300         1400         1500         1600         1700 
##            1           14            1            7            1           62            1            9 
##         1800         1900         2000         2100         2200         2300         2400         2500 
##           12            1           33            3            4            5            5           26 
##         2600         2700         2800         3000         3150         3200         3500         3600 
##            2            4            6           29            1            1            7            2 
##         4000         4100         4200         4500         4700         5000         5500 6000 or more 
##            3            1            2            4            2            5            1           14 
##         <NA> 
##           24

percentile_99.5 <- floor(quantile(na.exclude(mydata$s5q18)[na.exclude(mydata$s5q18)!=999999], probs = c(0.995)))
mydata <- top_recode (variable="s5q18", break_point=percentile_99.5, missing=999999)
## [1] "Frequency table before encoding"
## s5q18. What is the total value of these tricycles ?  Magkano ang kabuuang halaga ng (mg
##      0      8    150   3000   5000   6000   7000   8000  10000  11500  12000  15000  20000  24000  25000 
##   2134      5      2      1      2      2      1      2      3      1      2      4      7      3      2 
##  26992  27000  30000  32000  34000  35000  38000  40000  42000  45000  47000  49000  49500  50000  52000 
##      1      1      9      1      1      4      1     11      1      5      1      1      1     12      1 
##  52500  53800  54000  55000  56000  57000  57600  58000  60000  64800  65000  70000  72000  74000  74124 
##      1      1      1      1      1      1      1      1      4      1      2     10      1      1      1 
##  75000  76000  76416  78660  80000  80700  82800  89000  90000  93000  96000  1e+05 105000 109500 118000 
##      7      1      1      1      5      1      2      1      1      1      1     12      1      1      1 
## 120000 130000 150000 168000 218980   <NA> 
##      1      1      1      1      1      4

## [1] "Frequency table after encoding"
## s5q18. What is the total value of these tricycles ?  Magkano ang kabuuang halaga ng (mg
##             0             8           150          3000          5000          6000          7000 
##          2134             5             2             1             2             2             1 
##          8000         10000         11500         12000         15000         20000         24000 
##             2             3             1             2             4             7             3 
##         25000         26992         27000         30000         32000         34000         35000 
##             2             1             1             9             1             1             4 
##         38000         40000         42000         45000         47000         49000         49500 
##             1            11             1             5             1             1             1 
##         50000         52000         52500         53800         54000         55000         56000 
##            12             1             1             1             1             1             1 
##         57000         57600         58000         60000         64800         65000         70000 
##             1             1             1             4             1             2            10 
##         72000         74000         74124         75000         76000         76416         78660 
##             1             1             1             7             1             1             1 
##         80000         80700         82800         89000         90000         93000         96000 
##             5             1             2             1             1             1             1 
## 1e+05 or more          <NA> 
##            20             4

percentile_99.5 <- floor(quantile(na.exclude(mydata$s5q20)[na.exclude(mydata$s5q20)!=999999], probs = c(0.995)))
mydata <- top_recode (variable="s5q20", break_point=percentile_99.5, missing=999999)
## [1] "Frequency table before encoding"
## s5q20. What is the total value of these motorbikes?  Magkano ang kabuuang halaga ng (mg
##      0      5      8     15     17   1500   2000   2500   3000   4000   4500   4600   5000   6000   7000 
##   1875      1      1      1      1      1      5      1      6      3      2      1     18      3      2 
##   7800   8000  10000  10500  11600  12000  13000  14000  14700  15000  16000  17000  18000  20000  21000 
##      1      6     33      3      1      8      2      1      1     21      3      4      5     28      1 
##  21600  23000  24000  25000  25200  26000  27000  27200  28000  28500  28800  29000  30000  31000  31200 
##      1      2      3     11      1      1      1      1      1      1      1      1     30      2      1 
##  32000  32400  33000  34000  35000  36000  37000  37560  38000  40000  41000  42000  43000  43200  43740 
##      5      1      1      3      8      2      2      1      3     13      2      1      1      3      1 
##  44000  45000  46000  46800  47000  48000  48780  49800  50000  52000  52380  52800  53000  54000  55000 
##      2      7      2      1      2      3      1      1     19      1      1      1      1      6      2 
##  56000  57000  57600  60000  62000  63800  64000  64800  65000  65550  66060  67000  68000  68400  70000 
##      2      1      1     14      1      1      2      3      1      1      1      1      2      1      9 
##  72000  72540  74000  75000  75600  76000  77000  79200  80000  82000  82800  84000  85000  89000  90000 
##      2      1      1      3      2      1      2      1      4      1      2      1      1      1      1 
##  92000  93000  93600  97000  97200  1e+05 104600 110000 111600 120000 126900 130000 131000 140000 150000 
##      1      1      1      1      1      5      1      1      1      1      1      1      1      1      2 
##  2e+05 240000 320000   <NA> 
##      1      1      1     14

## [1] "Frequency table after encoding"
## s5q20. What is the total value of these motorbikes?  Magkano ang kabuuang halaga ng (mg
##              0              5              8             15             17           1500           2000 
##           1875              1              1              1              1              1              5 
##           2500           3000           4000           4500           4600           5000           6000 
##              1              6              3              2              1             18              3 
##           7000           7800           8000          10000          10500          11600          12000 
##              2              1              6             33              3              1              8 
##          13000          14000          14700          15000          16000          17000          18000 
##              2              1              1             21              3              4              5 
##          20000          21000          21600          23000          24000          25000          25200 
##             28              1              1              2              3             11              1 
##          26000          27000          27200          28000          28500          28800          29000 
##              1              1              1              1              1              1              1 
##          30000          31000          31200          32000          32400          33000          34000 
##             30              2              1              5              1              1              3 
##          35000          36000          37000          37560          38000          40000          41000 
##              8              2              2              1              3             13              2 
##          42000          43000          43200          43740          44000          45000          46000 
##              1              1              3              1              2              7              2 
##          46800          47000          48000          48780          49800          50000          52000 
##              1              2              3              1              1             19              1 
##          52380          52800          53000          54000          55000          56000          57000 
##              1              1              1              6              2              2              1 
##          57600          60000          62000          63800          64000          64800          65000 
##              1             14              1              1              2              3              1 
##          65550          66060          67000          68000          68400          70000          72000 
##              1              1              1              2              1              9              2 
##          72540          74000          75000          75600          76000          77000          79200 
##              1              1              3              2              1              2              1 
##          80000          82000          82800          84000          85000          89000          90000 
##              4              1              2              1              1              1              1 
##          92000          93000          93600          97000          97200          1e+05         104600 
##              1              1              1              1              1              5              1 
## 107812 or more           <NA> 
##             12             14

percentile_99.5 <- floor(quantile(na.exclude(mydata$s5q22)[na.exclude(mydata$s5q22)!=999999], probs = c(0.995)))
mydata <- top_recode (variable="s5q22", break_point=percentile_99.5, missing=999999)
## [1] "Frequency table before encoding"
## s5q22. What is the total value of these motorized boats/bancas ?  Magkano ang kabuuang 
##     0     8  1000  1400  1500  2000  2300  3000  4000  4500  5000  7000  8000 10000 12000 12500 13000 14000 
##  2173     3     2     1     2     3     1     1     1     1     5     2     2    14     2     1     1     1 
## 15000 16000 18000 19000 20000 23000 24000 25000 26800 29000 30000 32000 35000 39500 40000 45000 50000 56000 
##    15     1     2     1    12     1     1     6     1     1     9     1     2     1     6     1     4     1 
## 60000 68000 70000 75000 1e+05  <NA> 
##     4     1     4     1     1     3

## [1] "Frequency table after encoding"
## s5q22. What is the total value of these motorized boats/bancas ?  Magkano ang kabuuang 
##             0             8          1000          1400          1500          2000          2300 
##          2173             3             2             1             2             3             1 
##          3000          4000          4500          5000          7000          8000         10000 
##             1             1             1             5             2             2            14 
##         12000         12500         13000         14000         15000         16000         18000 
##             2             1             1             1            15             1             2 
##         19000         20000         23000         24000         25000         26800         29000 
##             1            12             1             1             6             1             1 
##         30000         32000         35000         39500         40000         45000         50000 
##             9             1             2             1             6             1             4 
## 53239 or more          <NA> 
##            12             3

percentile_99.5 <- floor(quantile(na.exclude(mydata$s5q24)[na.exclude(mydata$s5q24)!=999999], probs = c(0.995)))
mydata <- top_recode (variable="s5q24", break_point=percentile_99.5, missing=999999)
## [1] "Frequency table before encoding"
## s5q24. What is the total value of these other motorized vehicles?  Magkano ang kabuuang
##      0      8   1000   2000   2500   3000   5000   6000   8000  10000  12000  20000  25000  35000  70000 
##   2271      1      1      1      1      1      1      1      1      1      1      3      2      2      1 
##  2e+05 250000   <NA> 
##      2      1      4

## [1] "Frequency table after encoding"
## s5q24. What is the total value of these other motorized vehicles?  Magkano ang kabuuang
##             0             8          1000          2000          2500          3000          5000 
##          2271             1             1             1             1             1             1 
##          6000          8000         10000 11090 or more          <NA> 
##             1             1             1            12             4

percentile_99.5 <- floor(quantile(na.exclude(mydata$s5q26)[na.exclude(mydata$s5q26)!=999999], probs = c(0.995)))
mydata <- top_recode (variable="s5q26", break_point=percentile_99.5, missing=999999)
## [1] "Frequency table before encoding"
## s5q26. What is the total value of these radio, tape, or CD player ?  Magkano ang kabuua
##     0    10    20    30    35    40    50    55    64   100   120   150   180   200   250   270   275   300 
##  1327     2     4     1     1     1    19     1     1    47     2    31     1    57    27     1     1    69 
##   320   350   380   400   450   495   499   500   520   580   600   640   700   750   790   800   900  1000 
##     2    27     3    19     7     1     1   106     1     1    22     1    22     3     1    14     3    78 
##  1100  1200  1250  1300  1349  1400  1500  1600  1700  1800  1900  2000  2050  2150  2200  2400  2500  2700 
##     2    25     1     7     1     2    84     9     7     7     3    64     2     1     5     2    31     3 
##  2750  2800  3000  3200  3400  3500  3900  4000  4100  4500  5000  5400  5500  6000  7000  7800  8000  9000 
##     1     4    28     3     1     9     2     4     1     5     9     1     1     6     2     1     2     3 
## 10000 15000 19000 20000  <NA> 
##     2     5     1     1    43

## [1] "Frequency table after encoding"
## s5q26. What is the total value of these radio, tape, or CD player ?  Magkano ang kabuua
##            0           10           20           30           35           40           50           55 
##         1327            2            4            1            1            1           19            1 
##           64          100          120          150          180          200          250          270 
##            1           47            2           31            1           57           27            1 
##          275          300          320          350          380          400          450          495 
##            1           69            2           27            3           19            7            1 
##          499          500          520          580          600          640          700          750 
##            1          106            1            1           22            1           22            3 
##          790          800          900         1000         1100         1200         1250         1300 
##            1           14            3           78            2           25            1            7 
##         1349         1400         1500         1600         1700         1800         1900         2000 
##            1            2           84            9            7            7            3           64 
##         2050         2150         2200         2400         2500         2700         2750         2800 
##            2            1            5            2           31            3            1            4 
##         3000         3200         3400         3500         3900         4000         4100         4500 
##           28            3            1            9            2            4            1            5 
##         5000         5400         5500         6000         7000         7800         8000 8739 or more 
##            9            1            1            6            2            1            2           12 
##         <NA> 
##           43

percentile_99.5 <- floor(quantile(na.exclude(mydata$s5q28)[na.exclude(mydata$s5q28)!=999999], probs = c(0.995)))
mydata <- top_recode (variable="s5q28", break_point=percentile_99.5, missing=999999)
## [1] "Frequency table before encoding"
## s5q28. What is the total value of beds ?  Magkano ang kabuuang halaga ng (mga) kama?
##     0     2    20    30    40    50   100   150   160   200   250   300   350   400   405   500   550   600 
##  1392     1     3     1     1    12    49    19     1    86     9    65     2    30     1   147     1    24 
##   640   700   750   800   900  1000  1150  1200  1300  1400  1440  1500  1550  1600  1700  1800  1900  2000 
##     1    20     3    19     7   112     1    12     2     3     1    54     1     1     2     2     3    36 
##  2100  2200  2250  2300  2500  2600  2800  3000  3200  3500  3550  3600  3800  4000  4400  4500  4700  5000 
##     2     3     1     1    10     1     1    36     2    10     1     1     1     8     1     7     1    17 
##  5500  6000  6500  6900  7000  8000  8500  9000 10000 10500 11000 12000 13000 13500 15000 17000  <NA> 
##     2     3     1     1     3     3     1     1     5     1     1     2     2     1     2     1    38

## [1] "Frequency table after encoding"
## s5q28. What is the total value of beds ?  Magkano ang kabuuang halaga ng (mga) kama?
##             0             2            20            30            40            50           100 
##          1392             1             3             1             1            12            49 
##           150           160           200           250           300           350           400 
##            19             1            86             9            65             2            30 
##           405           500           550           600           640           700           750 
##             1           147             1            24             1            20             3 
##           800           900          1000          1150          1200          1300          1400 
##            19             7           112             1            12             2             3 
##          1440          1500          1550          1600          1700          1800          1900 
##             1            54             1             1             2             2             3 
##          2000          2100          2200          2250          2300          2500          2600 
##            36             2             3             1             1            10             1 
##          2800          3000          3200          3500          3550          3600          3800 
##             1            36             2            10             1             1             1 
##          4000          4400          4500          4700          5000          5500          6000 
##             8             1             7             1            17             2             3 
##          6500          6900          7000          8000          8500          9000 10000 or more 
##             1             1             3             3             1             1            15 
##          <NA> 
##            38

percentile_99.5 <- floor(quantile(na.exclude(mydata$s5q30)[na.exclude(mydata$s5q30)!=999999], probs = c(0.995)))
mydata <- top_recode (variable="s5q30", break_point=percentile_99.5, missing=999999)
## [1] "Frequency table before encoding"
## s5q30. What is the total value of these mattresses ?  Magkano ang kabuuang halaga ng (m
##     0     5     8    10    20    50    60   100   120   150   200   250   300   350   400   450   500   550 
##  1331     1     2     1     3    15     1    35     1     5    43     3    30     3     9     2    83     1 
##   600   650   700   800   900   960  1000  1100  1200  1300  1350  1400  1440  1450  1500  1600  1700  1800 
##    11     1    16    28     9     1   114     3    26     3     1     6     1     1    63     6     1    13 
##  1950  1999  2000  2100  2200  2250  2300  2400  2500  2600  2700  2800  2900  3000  3200  3300  3400  3500 
##     1     1    64     2     3     1     2     8    23     4     2    11     3    60    13     4     1    24 
##  3550  3600  3800  3900  4000  4100  4200  4400  4500  4600  4700  4800  4900  5000  5200  5400  5500  5600 
##     1     3     4     2    21     1     1     1    18     2     1     7     7    20     1     1     2     2 
##  5900  6000  6500  6800  7000  7200  7500  7600  7800  8000  8500  9000 10000 10500 11900 12800 13500 14800 
##     1    10     1     1     6     1     2     1     2     5     1     2     6     3     1     1     1     1 
## 16000 18000  <NA> 
##     1     1    53

## [1] "Frequency table after encoding"
## s5q30. What is the total value of these mattresses ?  Magkano ang kabuuang halaga ng (m
##             0             5             8            10            20            50            60 
##          1331             1             2             1             3            15             1 
##           100           120           150           200           250           300           350 
##            35             1             5            43             3            30             3 
##           400           450           500           550           600           650           700 
##             9             2            83             1            11             1            16 
##           800           900           960          1000          1100          1200          1300 
##            28             9             1           114             3            26             3 
##          1350          1400          1440          1450          1500          1600          1700 
##             1             6             1             1            63             6             1 
##          1800          1950          1999          2000          2100          2200          2250 
##            13             1             1            64             2             3             1 
##          2300          2400          2500          2600          2700          2800          2900 
##             2             8            23             4             2            11             3 
##          3000          3200          3300          3400          3500          3550          3600 
##            60            13             4             1            24             1             3 
##          3800          3900          4000          4100          4200          4400          4500 
##             4             2            21             1             1             1            18 
##          4600          4700          4800          4900          5000          5200          5400 
##             2             1             7             7            20             1             1 
##          5500          5600          5900          6000          6500          6800          7000 
##             2             2             1            10             1             1             6 
##          7200          7500          7600          7800          8000          8500          9000 
##             1             2             1             2             5             1             2 
## 10000 or more          <NA> 
##            15            53

percentile_99.5 <- floor(quantile(na.exclude(mydata$s5q32)[na.exclude(mydata$s5q32)!=999999], probs = c(0.995)))
mydata <- top_recode (variable="s5q32", break_point=percentile_99.5, missing=999999)
## [1] "Frequency table before encoding"
## s5q32. What is the total value of these solar panels?  Magkano ang kabuuang halaga ng (
##     0     8    25   100   150   200   250   255   280   285   300   350   500   600   800  1000  1500  2000 
##  2250     3     1     5     2     3     3     1     1     1     4     2     2     1     1     2     2     3 
##  2800  3000  3500  4800  9500 20000  <NA> 
##     1     1     1     1     1     1     3

## [1] "Frequency table after encoding"
## s5q32. What is the total value of these solar panels?  Magkano ang kabuuang halaga ng (
##            0            8           25          100          150          200          250          255 
##         2250            3            1            5            2            3            3            1 
##          280          285          300          350          500          600          800 1000 or more 
##            1            1            4            2            2            1            1           13 
##         <NA> 
##            3

percentile_99.5 <- floor(quantile(na.exclude(mydata$s5q34)[na.exclude(mydata$s5q34)!=999999], probs = c(0.995)))
mydata <- top_recode (variable="s5q34", break_point=percentile_99.5, missing=999999)
## [1] "Frequency table before encoding"
## s5q34. What is the total value of the generators?  Magkano ang kabuuang halaga ng (mga)
##     0     8  5000 10000 11000 80000  <NA> 
##  2285     3     1     2     1     1     3

## [1] "Frequency table after encoding"
## s5q34. What is the total value of the generators?  Magkano ang kabuuang halaga ng (mga)
## 0 or more      <NA> 
##      2293         3

percentile_99.5 <- floor(quantile(na.exclude(mydata$s5q36)[na.exclude(mydata$s5q36)!=999999], probs = c(0.995)))
mydata <- top_recode (variable="s5q36", break_point=percentile_99.5, missing=999999)
## [1] "Frequency table before encoding"
## s5q36. What is the total value of these televisions ?  Magkano ang kabuuang halaga ng (
##     0     1    20    25    40    50    60    75   100   150   200   250   300   400   450   500   550   600 
##   615     1     4     2     1    16     1     1    20     5    14     5    21     5     1    92     2     6 
##   650   700   800   900  1000  1030  1100  1200  1300  1400  1500  1550  1600  1700  1750  1799  1800  1900 
##     1    18    23     4   183     1     4    49     8    13   215     1    18    34     1     1    50    11 
##  1950  2000  2003  2100  2199  2200  2300  2400  2500  2600  2700  2800  2900  3000  3100  3200  3295  3300 
##     1   187     1     7     1    20     7     7    85     3     8    13     8   113     1     5     1     2 
##  3400  3408  3500  3600  3700  3800  3900  3999  4000  4200  4500  4600  4700  4800  5000  5100  5300  5600 
##     3     1    34     3     2     2     1     1    48     2    12     1     1     1    50     1     1     1 
##  5700  6000  6500  7000  7500  7800  8000  8200  8500  8680  9000  9500  9900 10000 10500 11000 12000 13000 
##     1    14     2    20     2     1    16     1     1     1     6     2     1    25     1     5     8     1 
## 14000 15000 16000 17000 18000 19000 19500 20000 21000 22000 23000 24000 25000 26000 27000 30000  <NA> 
##     6     9     2     1     3     3     1     5     1     2     1     1     4     1     1     2    63

## [1] "Frequency table after encoding"
## s5q36. What is the total value of these televisions ?  Magkano ang kabuuang halaga ng (
##             0             1            20            25            40            50            60 
##           615             1             4             2             1            16             1 
##            75           100           150           200           250           300           400 
##             1            20             5            14             5            21             5 
##           450           500           550           600           650           700           800 
##             1            92             2             6             1            18            23 
##           900          1000          1030          1100          1200          1300          1400 
##             4           183             1             4            49             8            13 
##          1500          1550          1600          1700          1750          1799          1800 
##           215             1            18            34             1             1            50 
##          1900          1950          2000          2003          2100          2199          2200 
##            11             1           187             1             7             1            20 
##          2300          2400          2500          2600          2700          2800          2900 
##             7             7            85             3             8            13             8 
##          3000          3100          3200          3295          3300          3400          3408 
##           113             1             5             1             2             3             1 
##          3500          3600          3700          3800          3900          3999          4000 
##            34             3             2             2             1             1            48 
##          4200          4500          4600          4700          4800          5000          5100 
##             2            12             1             1             1            50             1 
##          5300          5600          5700          6000          6500          7000          7500 
##             1             1             1            14             2            20             2 
##          7800          8000          8200          8500          8680          9000          9500 
##             1            16             1             1             1             6             2 
##          9900         10000         10500         11000         12000         13000         14000 
##             1            25             1             5             8             1             6 
##         15000         16000         17000         18000         19000         19500         20000 
##             9             2             1             3             3             1             5 
##         21000 21840 or more          <NA> 
##             1            12            63

percentile_99.5 <- floor(quantile(na.exclude(mydata$s5q38)[na.exclude(mydata$s5q38)!=999999], probs = c(0.995)))
mydata <- top_recode (variable="s5q38", break_point=percentile_99.5, missing=999999)
## [1] "Frequency table before encoding"
## s5q38. What is the total value of these VCRs/DVD players?  Magkano ang kabuuang halaga 
##     0     8    10    20    30    40    50   100   150   200   208   210   250   300   350   400   500   520 
##  1549     3     4     3     3     1    16    14     6    11     1     1     1    20     2     9   109     1 
##   550   600   700   750   800   900  1000  1100  1200  1250  1300  1349  1365  1400  1450  1500  1600  1700 
##     1     6    12     1    15     3   120     6    52     2    14     1     1     9     1   128     8    10 
##  1750  1800  1900  2000  2200  2300  2400  2500  2700  2800  3000  3200  3300  3500  3600  3700  3800  3900 
##     1     9     3    45     4     1     3    12     1     2    15     1     1     2     1     1     1     2 
##  4000  4500  5000  6000  8000 10000 13000 16000 50000  <NA> 
##     7     1     6     3     1     4     1     1     1    22

## [1] "Frequency table after encoding"
## s5q38. What is the total value of these VCRs/DVD players?  Magkano ang kabuuang halaga 
##            0            8           10           20           30           40           50          100 
##         1549            3            4            3            3            1           16           14 
##          150          200          208          210          250          300          350          400 
##            6           11            1            1            1           20            2            9 
##          500          520          550          600          700          750          800          900 
##          109            1            1            6           12            1           15            3 
##         1000         1100         1200         1250         1300         1349         1365         1400 
##          120            6           52            2           14            1            1            9 
##         1450         1500         1600         1700         1750         1800         1900         2000 
##            1          128            8           10            1            9            3           45 
##         2200         2300         2400         2500         2700         2800         3000         3200 
##            4            1            3           12            1            2           15            1 
##         3300         3500         3600         3700         3800         3900         4000         4500 
##            1            2            1            1            1            2            7            1 
## 5000 or more         <NA> 
##           17           22

percentile_99.5 <- floor(quantile(na.exclude(mydata$s5q40)[na.exclude(mydata$s5q40)!=999999], probs = c(0.995)))
mydata <- top_recode (variable="s5q40", break_point=percentile_99.5, missing=999999)
## [1] "Frequency table before encoding"
## s5q40. What is the total value of these computer ?  Magkano ang kabuuang halaga ng (mga
##     0     1   200  1000  1500  1600  2000  2500  3000  4000  4500  5000  6000  6500  7000 12000 13000 13500 
##  2240     1     2     2     1     1     2     1     2     1     2     7     1     1     3     3     1     1 
## 15000 16000 17000 18000 22000 24000 26000 34000 57000 60000  <NA> 
##     5     1     1     1     1     1     1     1     1     1    10

## [1] "Frequency table after encoding"
## s5q40. What is the total value of these computer ?  Magkano ang kabuuang halaga ng (mga
##             0             1           200          1000          1500          1600          2000 
##          2240             1             2             2             1             1             2 
##          2500          3000          4000          4500          5000          6000          6500 
##             1             2             1             2             7             1             1 
##          7000         12000         13000         13500 15000 or more          <NA> 
##             3             3             1             1            14            10

percentile_99.5 <- floor(quantile(na.exclude(mydata$s5q42)[na.exclude(mydata$s5q42)!=999999], probs = c(0.995)))
mydata <- top_recode (variable="s5q42", break_point=percentile_99.5, missing=999999)
## [1] "Frequency table before encoding"
## s5q42. What is the total value of farm tools ?  Magkano ang kabuuang halaga ng (mga) ka
##      0      5      8     20     30     35     50     60     75    100    120    150    180    200    230 
##   1637      1      1      2      3      1     17      1      1     41      2     25      2     35      1 
##    250    280    300    320    350    360    380    400    440    450    500    520    540    550    594 
##     13      2     32      1     10      2      2     23      1     15     53      1      1      1      1 
##    600    610    620    650    700    720    750    770    780    800    840    850    900    940    950 
##     22      1      1      2     15      1      4      1      1     12      1      3      6      1      2 
##   1000   1050   1100   1130   1150   1200   1245   1250   1300   1350   1400   1420   1500   1550   1600 
##     48      1      2      1      1      6      1      1      5      1      6      1     30      1      1 
##   1700   1750   1800   1900   2000   2050   2100   2200   2250   2400   2500   2550   2600   2700   2800 
##      3      1      2      3     25      1      3      1      1      1     14      1      1      2      3 
##   2850   2900   3000   3150   3400   3500   3550   3800   4000   4100   4500   4600   4800   4950   5000 
##      1      3     25      1      1      4      1      1     10      1      4      1      1      1     13 
##   5200   5300   5500   5750   6000   6300   6600   7000   7500   8000   9000   9600  10000  12000  15000 
##      1      1      1      1      5      1      1      1      1      2      1      1      4      1      7 
##  17000  18000  20000  25000  26000  27000  30000  31350  33000  35000  42000  45000  75000  80000 111700 
##      1      2      1      1      1      1      2      1      1      2      1      1      1      1      1 
## 189000   <NA> 
##      1     11

## [1] "Frequency table after encoding"
## s5q42. What is the total value of farm tools ?  Magkano ang kabuuang halaga ng (mga) ka
##             0             5             8            20            30            35            50 
##          1637             1             1             2             3             1            17 
##            60            75           100           120           150           180           200 
##             1             1            41             2            25             2            35 
##           230           250           280           300           320           350           360 
##             1            13             2            32             1            10             2 
##           380           400           440           450           500           520           540 
##             2            23             1            15            53             1             1 
##           550           594           600           610           620           650           700 
##             1             1            22             1             1             2            15 
##           720           750           770           780           800           840           850 
##             1             4             1             1            12             1             3 
##           900           940           950          1000          1050          1100          1130 
##             6             1             2            48             1             2             1 
##          1150          1200          1245          1250          1300          1350          1400 
##             1             6             1             1             5             1             6 
##          1420          1500          1550          1600          1700          1750          1800 
##             1            30             1             1             3             1             2 
##          1900          2000          2050          2100          2200          2250          2400 
##             3            25             1             3             1             1             1 
##          2500          2550          2600          2700          2800          2850          2900 
##            14             1             1             2             3             1             3 
##          3000          3150          3400          3500          3550          3800          4000 
##            25             1             1             4             1             1            10 
##          4100          4500          4600          4800          4950          5000          5200 
##             1             4             1             1             1            13             1 
##          5300          5500          5750          6000          6300          6600          7000 
##             1             1             1             5             1             1             1 
##          7500          8000          9000          9600         10000         12000         15000 
##             1             2             1             1             4             1             7 
##         17000         18000         20000         25000         26000         27000 28739 or more 
##             1             2             1             1             1             1            12 
##          <NA> 
##            11

percentile_99.5 <- floor(quantile(na.exclude(mydata$s5q44)[na.exclude(mydata$s5q44)!=999999], probs = c(0.995)))
mydata <- top_recode (variable="s5q44", break_point=percentile_99.5, missing=999999)
## [1] "Frequency table before encoding"
## s5q44. What is the total value of wheelbarrows ?  Magkano ang kabuuang halaga ng (mga) 
##     0     8   100   150   200   500   600   700   800   900  1000  1500  1700  2000  2500  2600  4000 24000 
##  2262     2     2     2     1     5     1     2     1     1     5     1     1     1     2     1     2     1 
##  <NA> 
##     3

## [1] "Frequency table after encoding"
## s5q44. What is the total value of wheelbarrows ?  Magkano ang kabuuang halaga ng (mga) 
##            0            8          100          150          200          500          600          700 
##         2262            2            2            2            1            5            1            2 
##          800          900 1000 or more         <NA> 
##            1            1           14            3

percentile_99.5 <- floor(quantile(na.exclude(mydata$s5q46)[na.exclude(mydata$s5q46)!=999999], probs = c(0.995)))
mydata <- top_recode (variable="s5q46", break_point=percentile_99.5, missing=999999)
## [1] "Frequency table before encoding"
## s5q46. What is the total value of these carts ?  Magkano ang kabuuang halaga ng (mga) k
##     0     8    50   100   150   200   250   300   500   600   780  1000  1500  1800  2000  2500  3000  3500 
##  2188     4     2     2     1     2     1     2     2     1     1     8     6     1     9     7    13     1 
##  4000  4500  5000  5500  6000  7000  7500  8000  9000 10000 13500 17000  <NA> 
##     5     3    14     1     3     4     1     1     1     4     1     1     6

## [1] "Frequency table after encoding"
## s5q46. What is the total value of these carts ?  Magkano ang kabuuang halaga ng (mga) k
##            0            8           50          100          150          200          250          300 
##         2188            4            2            2            1            2            1            2 
##          500          600          780         1000         1500         1800         2000         2500 
##            2            1            1            8            6            1            9            7 
##         3000         3500         4000         4500         5000         5500         6000 7000 or more 
##           13            1            5            3           14            1            3           13 
##         <NA> 
##            6

percentile_99.5 <- floor(quantile(na.exclude(mydata$s5q48)[na.exclude(mydata$s5q48)!=999999], probs = c(0.995)))
mydata <- top_recode (variable="s5q48", break_point=percentile_99.5, missing=999999)
## [1] "Frequency table before encoding"
## s5q48. What is the total value of these kerosene or propane stove ?  Magkano ang kabuua
##     0     5     8    30    50   150   200   250   300   350   375   380   400   420   425   430   435   450 
##  2027     1     5     1     1     2     5     2     9     3     1     1     4     2     1     1     1     4 
##   480   490   500   530   550   580   595   600   700   750   800   900  1000  1100  1146  1200  1250  1300 
##     1     1    39     1     1     1     1     5    12     2     5     5    32     5     1    21     1     3 
##  1400  1500  1600  1700  1750  1800  1900  2000  2100  2200  2250  2300  2400  2500  2700  2900  3000  3100 
##     2    15     2     5     1     5     2    14     1     2     1     1     1     7     1     1     9     2 
##  3400  3600  4500 15000  <NA> 
##     1     1     1     1    12

## [1] "Frequency table after encoding"
## s5q48. What is the total value of these kerosene or propane stove ?  Magkano ang kabuua
##            0            5            8           30           50          150          200          250 
##         2027            1            5            1            1            2            5            2 
##          300          350          375          380          400          420          425          430 
##            9            3            1            1            4            2            1            1 
##          435          450          480          490          500          530          550          580 
##            1            4            1            1           39            1            1            1 
##          595          600          700          750          800          900         1000         1100 
##            1            5           12            2            5            5           32            5 
##         1146         1200         1250         1300         1400         1500         1600         1700 
##            1           21            1            3            2           15            2            5 
##         1750         1800         1900         2000         2100         2200         2250         2300 
##            1            5            2           14            1            2            1            1 
##         2400         2500         2700         2900 3000 or more         <NA> 
##            1            7            1            1           15           12

percentile_99.5 <- floor(quantile(na.exclude(mydata$s5q50)[na.exclude(mydata$s5q50)!=999999], probs = c(0.995)))
mydata <- top_recode (variable="s5q50", break_point=percentile_99.5, missing=999999)
## [1] "Frequency table before encoding"
## s5q50. What is the total value of these stoves with ovens/gas ranges ?  Magkano ang kab
##     0     8     9    10    20    30    40    50    75    80   100   130   150   200   230   250   300   400 
##  2011     4     1     1     3     1     1     9     1     2     2     1     3     9     1     1    12     4 
##   420   450   500   550   599   600   650   700   750   800   850   900   950   995  1000  1100  1200  1300 
##     1     2    25     3     1    12     2    19     3    16     2     4     1     1    22     2    15     3 
##  1400  1500  1600  1700  1900  2000  2200  2300  2400  2500  2800  3000  3200  3500  3700  4100  4500  5000 
##     2    25     4     3     2    15     2     1     1    11     3     6     2     1     1     1     1     1 
##  5500  6000 13000  <NA> 
##     1     1     1    10

## [1] "Frequency table after encoding"
## s5q50. What is the total value of these stoves with ovens/gas ranges ?  Magkano ang kab
##            0            8            9           10           20           30           40           50 
##         2011            4            1            1            3            1            1            9 
##           75           80          100          130          150          200          230          250 
##            1            2            2            1            3            9            1            1 
##          300          400          420          450          500          550          599          600 
##           12            4            1            2           25            3            1           12 
##          650          700          750          800          850          900          950          995 
##            2           19            3           16            2            4            1            1 
##         1000         1100         1200         1300         1400         1500         1600         1700 
##           22            2           15            3            2           25            4            3 
##         1900         2000         2200         2300         2400         2500         2800 3000 or more 
##            2           15            2            1            1           11            3           16 
##         <NA> 
##           10

percentile_99.5 <- floor(quantile(na.exclude(mydata$s5q52)[na.exclude(mydata$s5q52)!=999999], probs = c(0.995)))
mydata <- top_recode (variable="s5q52", break_point=percentile_99.5, missing=999999)
## [1] "Frequency table before encoding"
## s5q52. What is the total value of these refrigerators ?  Magkano ang kabuuang halaga ng
##     0     8    50   150   200   250   300   500   700  1000  1500  2000  2500  3000  3200  3500  4000  4300 
##  2011     3     1     2     5     1     1    10     1    15     8    20     3    21     1     7     4     1 
##  4500  5000  6000  6500  7000  7200  7500  8000  8500  8700  9000  9500 10000 10500 11000 11300 11500 12000 
##     2    21     9     1    18     1     1    16     1     1     7     1    24     1     8     1     2     9 
## 13000 14000 15000 16000 16500 17000 17500 18000 20000 21000 22000 24000 25000 30000  <NA> 
##     7     4     1     4     1     1     1     7     3     2     2     1     1     2    20

## [1] "Frequency table after encoding"
## s5q52. What is the total value of these refrigerators ?  Magkano ang kabuuang halaga ng
##             0             8            50           150           200           250           300 
##          2011             3             1             2             5             1             1 
##           500           700          1000          1500          2000          2500          3000 
##            10             1            15             8            20             3            21 
##          3200          3500          4000          4300          4500          5000          6000 
##             1             7             4             1             2            21             9 
##          6500          7000          7200          7500          8000          8500          8700 
##             1            18             1             1            16             1             1 
##          9000          9500         10000         10500         11000         11300         11500 
##             7             1            24             1             8             1             2 
##         12000         13000         14000         15000         16000         16500         17000 
##             9             7             4             1             4             1             1 
##         17500 18000 or more          <NA> 
##             1            18            20

percentile_99.5 <- floor(quantile(na.exclude(mydata$s5q54)[na.exclude(mydata$s5q54)!=999999], probs = c(0.995)))
mydata <- top_recode (variable="s5q54", break_point=percentile_99.5, missing=999999)
## [1] "Frequency table before encoding"
## s5q54. What is the total value of these clothes washing machines ?  Magkano ang kabuuan
##     0     8    30    50   100   150   200   300   400   500   700   800  1000  1200  1500  1600  1700  1800 
##  1855     1     1     1     5     1     5     5     1    20     8     4    29     2    25     2     1     5 
##  1900  2000  2100  2200  2300  2400  2500  2600  2700  2800  2850  2900  3000  3025  3100  3200  3400  3500 
##     2    36     3     4     3     7    42     7    12     6     1     3    38     1     1     9     1    20 
##  3600  3700  3900  4000  4100  4200  4250  4400  4500  4700  5000  5500  6000  6300  6500  7000  7200  7500 
##     1     2     1    15     1     4     1     1    10     2    23     5    13     1     3     7     1     3 
##  8000  9000 10000 11000 12000 13000 15000 45000  <NA> 
##     3     3     4     1     3     2     1     1    17

## [1] "Frequency table after encoding"
## s5q54. What is the total value of these clothes washing machines ?  Magkano ang kabuuan
##            0            8           30           50          100          150          200          300 
##         1855            1            1            1            5            1            5            5 
##          400          500          700          800         1000         1200         1500         1600 
##            1           20            8            4           29            2           25            2 
##         1700         1800         1900         2000         2100         2200         2300         2400 
##            1            5            2           36            3            4            3            7 
##         2500         2600         2700         2800         2850         2900         3000         3025 
##           42            7           12            6            1            3           38            1 
##         3100         3200         3400         3500         3600         3700         3900         4000 
##            1            9            1           20            1            2            1           15 
##         4100         4200         4250         4400         4500         4700         5000         5500 
##            1            4            1            1           10            2           23            5 
##         6000         6300         6500         7000         7200         7500         8000         9000 
##           13            1            3            7            1            3            3            3 
## 9610 or more         <NA> 
##           12           17

percentile_99.5 <- floor(quantile(na.exclude(mydata$s5q56)[na.exclude(mydata$s5q56)!=999999], probs = c(0.995)))
mydata <- top_recode (variable="s5q56", break_point=percentile_99.5, missing=999999)
## [1] "Frequency table before encoding"
## s5q56. What is the total value of these air conditioners ?  Magkano ang kabuuang halaga
##    0    8 3000 8000 <NA> 
## 2290    1    1    1    3

## [1] "Frequency table after encoding"
## s5q56. What is the total value of these air conditioners ?  Magkano ang kabuuang halaga
## 0 or more      <NA> 
##      2293         3

percentile_99.5 <- floor(quantile(na.exclude(mydata$s5q56b)[na.exclude(mydata$s5q56b)!=999999], probs = c(0.995)))
mydata <- top_recode (variable="s5q56b", break_point=percentile_99.5, missing=999999)
## [1] "Frequency table before encoding"
## s5q56b. What is the total value of these electric fans ?  Magkano ang kabuuang halaga ng
##     0     5     8    10    15    20    30    35    40    50    60    80    85    90    95   100   120   130 
##   819     1     3     3     1     9     1     1     3    26     1     2     1     2     1    42     3     1 
##   150   160   175   180   199   200   210   240   250   300   308   330   350   360   380   400   450   475 
##    21     1     1     1     1    73     1     1    11   103     1     1    17     2     1    43    13     1 
##   480   499   500   529   549   550   570   580   599   600   620   645   650   660   680   690   695   699 
##     1     3   203     1     1    13     1     3     1    75     1     1    18     1     5     1     1     2 
##   700   721   725   730   750   755   775   799   800   830   850   900   945   950   960   990   998   999 
##   113     1     1     1    17     1     1     1    69     1     6    29     1     4     1     1     1     2 
##  1000  1050  1064  1100  1150  1160  1200  1250  1280  1300  1350  1380  1400  1450  1470  1497  1500  1540 
##   111     1     1    15     1     1    43     2     1    14     1     1    29     1     1     1    80     1 
##  1550  1575  1600  1650  1700  1800  1900  2000  2100  2200  2250  2300  2350  2400  2500  2550  2600  2700 
##     2     1     9     1     8     9     4    34     2     3     1     5     1     5    13     1     3     2 
##  2750  2900  3000  3100  3200  3500  4000  4500  5000  5500  9000 17400  <NA> 
##     1     2    15     4     1     2     1     3     2     1     1     1    57

## [1] "Frequency table after encoding"
## s5q56b. What is the total value of these electric fans ?  Magkano ang kabuuang halaga ng
##            0            5            8           10           15           20           30           35 
##          819            1            3            3            1            9            1            1 
##           40           50           60           80           85           90           95          100 
##            3           26            1            2            1            2            1           42 
##          120          130          150          160          175          180          199          200 
##            3            1           21            1            1            1            1           73 
##          210          240          250          300          308          330          350          360 
##            1            1           11          103            1            1           17            2 
##          380          400          450          475          480          499          500          529 
##            1           43           13            1            1            3          203            1 
##          549          550          570          580          599          600          620          645 
##            1           13            1            3            1           75            1            1 
##          650          660          680          690          695          699          700          721 
##           18            1            5            1            1            2          113            1 
##          725          730          750          755          775          799          800          830 
##            1            1           17            1            1            1           69            1 
##          850          900          945          950          960          990          998          999 
##            6           29            1            4            1            1            1            2 
##         1000         1050         1064         1100         1150         1160         1200         1250 
##          111            1            1           15            1            1           43            2 
##         1280         1300         1350         1380         1400         1450         1470         1497 
##            1           14            1            1           29            1            1            1 
##         1500         1540         1550         1575         1600         1650         1700         1800 
##           80            1            2            1            9            1            8            9 
##         1900         2000         2100         2200         2250         2300         2350         2400 
##            4           34            2            3            1            5            1            5 
##         2500         2550         2600         2700         2750         2900         3000         3100 
##           13            1            3            2            1            2           15            4 
## 3180 or more         <NA> 
##           12           57

percentile_99.5 <- floor(quantile(na.exclude(mydata$s5q56fishnet2)[na.exclude(mydata$s5q56fishnet2)!=999999], probs = c(0.995)))
mydata <- top_recode (variable="s5q56fishnet2", break_point=percentile_99.5, missing=999999)
## [1] "Frequency table before encoding"
## s5q56fishnet2. What is the total value of these fishing nets ?  Ano ang kabuuang halaga ng mga 
##     0     2     8    50   100   150   180   200   250   260   300   320   380   400   450   500   600   690 
##  2062     1     1     4     4     2     1     3     1     1     8     1     1     2     1    13     2     1 
##   700   750   800   900   980   990  1000  1010  1200  1500  1600  1650  1700  1750  2000  2100  2200  2400 
##     3     1     4     2     1     1    26     1     4    19     2     1     1     1    13     1     1     1 
##  2500  2600  2800  3000  3400  3500  3780  4000  4500  4700  4750  5000  6000  7000  8000  9500 10000 12000 
##     9     1     2    21     1     1     1     6     1     1     1    14     3     4     3     1     8     1 
## 13000 15000 18000 20000 24000 26000 30000 35000 40000 60000 1e+05  <NA> 
##     1     5     1     6     2     1     2     1     1     1     1     3

## [1] "Frequency table after encoding"
## s5q56fishnet2. What is the total value of these fishing nets ?  Ano ang kabuuang halaga ng mga 
##             0             2             8            50           100           150           180 
##          2062             1             1             4             4             2             1 
##           200           250           260           300           320           380           400 
##             3             1             1             8             1             1             2 
##           450           500           600           690           700           750           800 
##             1            13             2             1             3             1             4 
##           900           980           990          1000          1010          1200          1500 
##             2             1             1            26             1             4            19 
##          1600          1650          1700          1750          2000          2100          2200 
##             2             1             1             1            13             1             1 
##          2400          2500          2600          2800          3000          3400          3500 
##             1             9             1             2            21             1             1 
##          3780          4000          4500          4700          4750          5000          6000 
##             1             6             1             1             1            14             3 
##          7000          8000          9500         10000         12000         13000         15000 
##             4             3             1             8             1             1             5 
##         18000 20000 or more          <NA> 
##             1            15             3

percentile_99.5 <- floor(quantile(na.exclude(mydata$s5q56pedicab2)[na.exclude(mydata$s5q56pedicab2)!=999999], probs = c(0.995)))
mydata <- top_recode (variable="s5q56pedicab2", break_point=percentile_99.5, missing=999999)
## [1] "Frequency table before encoding"
## s5q56pedicab2. What is the total value of these pedicabs?  Ano ang kabuuang halaga ng mga pedic
##     0     8   300   336   500   700  1000  1500  2000  2100  3000  3500  4000  4200  4500  5000  5600  6000 
##  2203     3     1     1     3     1     4     5     5     1     9     1     6     1     4    14     1     5 
##  7000  8000  9000 10000 12000 13000 14000 20000 21000 21600 25000 35000 80000  <NA> 
##     3     3     1     3     2     1     1     1     1     4     2     1     1     4

## [1] "Frequency table after encoding"
## s5q56pedicab2. What is the total value of these pedicabs?  Ano ang kabuuang halaga ng mga pedic
##             0             8           300           336           500           700          1000 
##          2203             3             1             1             3             1             4 
##          1500          2000          2100          3000          3500          4000          4200 
##             5             5             1             9             1             6             1 
##          4500          5000          5600          6000          7000          8000          9000 
##             4            14             1             5             3             3             1 
##         10000         12000 12545 or more          <NA> 
##             3             2            12             4

percentile_99.5 <- floor(quantile(na.exclude(mydata$s5q56ricestock2)[na.exclude(mydata$s5q56ricestock2)!=999999], probs = c(0.995)))
mydata <- top_recode (variable="s5q56ricestock2", break_point=percentile_99.5, missing=999999)
## [1] "Frequency table before encoding"
## s5q56ricestock2. What is the total value of these rice stocks?  Ano ang kabuuang halaga ng ipon n
##     0     7     8    20    32    34    35    36    38    40    45    50    51    56    60    62    64    66 
##  1800     1     1     1     1     1     9     1     1     2     2     1     1     1     4     2     4     3 
##    70    72    74    80    82    86    90    92    96    98    99   100   102   105   108   110   113   114 
##     9     4     1     4     1     1     5     1     3     1     1     2     1     5     2     1     1     1 
##   116   120   126   128   130   135   138   140   145   150   160   165   170   175   180   188   189   190 
##     1     2     2     1     1     1     1     1     1     7     6     4     3     5     3     1     1     1 
##   198   200   210   215   233   238   252   265   270   280   300   308   320   324   330   336   340   350 
##     1     6     3     1     1     1     1     1     2     1     8     1     6     1     2     1     1    11 
##   360   370   378   380   400   408   410   420   429   430   450   465   473   500   504   525   540   544 
##     4     1     1     5     8     1     1     3     1     1     5     1     1     8     1     1     3     1 
##   550   555   600   620   640   660   680   700   720   722   725   740   750   800   810   825   850   875 
##     1     1     7     1     2     1     1    14     1     1     1     1    14    10     1     1     6     3 
##   900   920   925   930   950  1000  1015  1025  1050  1100  1150  1155  1200  1250  1280  1300  1350  1400 
##    10     2     1     1     1    16     1     1     4     2     1     1    12     1     1     1     1     1 
##  1500  1550  1600  1700  1750  1800  1900  2000  2100  2200  2250  2300  2500  2520  2600  2800  3000  3060 
##    20     1     6     1     1     9     1    19     4     1     1     1     4     1     1     1    10     1 
##  3185  3440  3500  3600  3825  4000  4200  4400  4500  4550  4800  4900  5000  5400  5530  5600  5850  6000 
##     1     1     1     2     1     3     4     1     4     1     3     1     4     1     1     1     1     2 
##  6600  6700  6750  6800  7000  7176  7200  7400  7500  7650  7800  8000  8400  8800  9000  9180  9600  9750 
##     1     1     1     1     1     1     1     1     1     1     1     2     2     1     1     1     1     1 
## 10000 10800 11200 12800 13500 14400 15000 18900 34200  <NA> 
##     2     2     1     1     3     1     1     1     1     4

## [1] "Frequency table after encoding"
## s5q56ricestock2. What is the total value of these rice stocks?  Ano ang kabuuang halaga ng ipon n
##             0             7             8            20            32            34            35 
##          1800             1             1             1             1             1             9 
##            36            38            40            45            50            51            56 
##             1             1             2             2             1             1             1 
##            60            62            64            66            70            72            74 
##             4             2             4             3             9             4             1 
##            80            82            86            90            92            96            98 
##             4             1             1             5             1             3             1 
##            99           100           102           105           108           110           113 
##             1             2             1             5             2             1             1 
##           114           116           120           126           128           130           135 
##             1             1             2             2             1             1             1 
##           138           140           145           150           160           165           170 
##             1             1             1             7             6             4             3 
##           175           180           188           189           190           198           200 
##             5             3             1             1             1             1             6 
##           210           215           233           238           252           265           270 
##             3             1             1             1             1             1             2 
##           280           300           308           320           324           330           336 
##             1             8             1             6             1             2             1 
##           340           350           360           370           378           380           400 
##             1            11             4             1             1             5             8 
##           408           410           420           429           430           450           465 
##             1             1             3             1             1             5             1 
##           473           500           504           525           540           544           550 
##             1             8             1             1             3             1             1 
##           555           600           620           640           660           680           700 
##             1             7             1             2             1             1            14 
##           720           722           725           740           750           800           810 
##             1             1             1             1            14            10             1 
##           825           850           875           900           920           925           930 
##             1             6             3            10             2             1             1 
##           950          1000          1015          1025          1050          1100          1150 
##             1            16             1             1             4             2             1 
##          1155          1200          1250          1280          1300          1350          1400 
##             1            12             1             1             1             1             1 
##          1500          1550          1600          1700          1750          1800          1900 
##            20             1             6             1             1             9             1 
##          2000          2100          2200          2250          2300          2500          2520 
##            19             4             1             1             1             4             1 
##          2600          2800          3000          3060          3185          3440          3500 
##             1             1            10             1             1             1             1 
##          3600          3825          4000          4200          4400          4500          4550 
##             2             1             3             4             1             4             1 
##          4800          4900          5000          5400          5530          5600          5850 
##             3             1             4             1             1             1             1 
##          6000          6600          6700          6750          6800          7000          7176 
##             2             1             1             1             1             1             1 
##          7200          7400          7500          7650          7800          8000          8400 
##             1             1             1             1             1             2             2 
##          8800          9000          9180          9600          9750 10000 or more          <NA> 
##             1             1             1             1             1            13             4

mydata <- mydata[!names(mydata) %in% "s5q58_month"]

Indirect PII - Categorical: Recode, encode, or Top/bottom coding for extreme values

# !!!Include relevant variables in list below (Indirect PII - Categorical, and Ordinal if not processed yet)

indirect_PII <- c("s5q57",
                  "s5q63",
                  "s5q65_1",
                  "s5q65_2")

capture_tables (indirect_PII)



# Recode those with very specific values. 
val_labels(mydata$s5q65_1)
## -999. No Response           1. GSIS            2. SSS   3. Scholarships  4. Other:Specify 
##              -999                 1                 2                 3                 4
break_transfers <- c(1,2,3,4)
labels_tranfers <- c("GSIS"=1,
                "Other" = 2,
                "Scholarships" = 3,
                "other: Specify"=4)
mydata <- ordinal_recode (variable="s5q65_1", break_points=break_transfers, missing=999999, value_labels=labels_tranfers)

## [1] "Frequency table before encoding"
## s5q65_1. In the past 12 months, what government transfers did you receive?  Sa nakaraang 
##           2. SSS  3. Scholarships 4. Other:Specify             <NA> 
##               26               82               46             2142 
##    recoded
##     [1,2) [2,3) [3,4) [4,1e+06)
##   2     0    26     0         0
##   3     0     0    82         0
##   4     0     0     0        46
## [1] "Frequency table after encoding"
## s5q65_1. In the past 12 months, what government transfers did you receive?  Sa nakaraang 
##          Other   Scholarships other: Specify           <NA> 
##             26             82             46           2142 
## [1] "Inspect value labels and relabel as necessary"
##           GSIS          Other   Scholarships other: Specify 
##              1              2              3              4

Matching and crosstabulations: Run automated PII check

# !!! Insufficient demographic data

Open-ends: review responses for any sensitive information, redact as necessary

# !!! Identify open-end variables here: 
open_ends <- c("s5q1whynoresponse",
               "s5q3whynoresponse",
               "s5q5whynoresponse",
               "s5q7whynoresponse",
               "s5q9whynoresponse",
               "s5q11whynoresponse",
               "s5q13whynoresponse",
               "s5q15whynoresponse",
               "s5q17whynoresponse",
               "s5q19whynoresponse",
               "s5q21whynoresponse",
               "s5q23whynoresponse",
               "s5q25whynoresponse",
               "s5q27whynoresponse",
               "s5q29whynoresponse",
               "s5q31whynoresponse",
               "s5q33whynoresponse",
               "s5q35whynoresponse",
               "s5q37whynoresponse",
               "s5q39whynoresponse",
               "s5q41whynoresponse",
               "s5q43whynoresponse",
               "s5q45whynoresponse",
               "s5q47whynoresponse",
               "s5q49whynoresponse",
               "s5q51whynoresponse",
               "s5q53whynoresponse",
               "s5q55whynoresponse",
               "s5q56awhynoresponse",
               "s5q56fishnetwhynoresponse",
               "s5q56pedicabwhynoresponse",
               "s5q56ricestockwhynoresponse",
               "s5q57whynoresponse",
               "s5q59whynoresponse",
               "s5q60whynoresponse",
               "s5q61whynoresponse",
               "s5q62whynoresponse",
               "s5q63whynoresponse",
               "s5q64whynoresponse",
               "s5q65whynoresponse",
               "s5q65other")

report_open (list_open_ends = open_ends)

# Review "verbatims.csv". Identify variables to be deleted or redacted and their row number 


mydata$s5q1whynoresponse[50] <- "Materials was provided by Gold sun"
mydata$s5q1whynoresponse[97] <- "[Tagalog]"
mydata$s5q1whynoresponse[745] <- "Father owned the house and [situation]"
mydata$s5q1whynoresponse[961] <- "She cannot estimate the price because of the quality of their house"
mydata$s5q1whynoresponse[1026] <- "She does not know and does not want to answer. The house is owned by the [person]."
mydata$s5q1whynoresponse[1100] <- "Cannot estimate because the house is made only in a [type of materials]"
mydata$s5q1whynoresponse[1156] <- "Their house is made by [object]."
mydata$s5q1whynoresponse[1161] <- "Cannot assess value inherited house and lot, but  the house and lot is big I think is almost [amount] sq.m."
mydata$s5q1whynoresponse[1448] <- "Materials came from [site]."
mydata$s5q1whynoresponse[1449] <- "[Type of materials]"

mydata$s5q7whynoresponse[1512] <- "They dont want to give any amount even if ill tell is is it [amount redacted]???"
mydata$s5q9whynoresponse[139] <- "[name] only repaired it"

mydata$s5q13whynoresponse[157] <- "[Tagalog]"
mydata$s5q13whynoresponse[139] <- "Came from a [person]"

mydata$s5q29whynoresponse[1451] <- "Came from [foundation]"

mydata$s5q51whynoresponse[1294] <- "[Person redacted]"

mydata$s5q56awhynoresponse[615] <- "Raffle price ([amount redacted])"

mydata$s5q56fishnetwhynoresponse[1078] <- "2 or more"

mydata$s5q56ricestockwhynoresponse[55] <- "[amount redacted] rice stocks. Total value of [amount redacted]"
mydata$s5q56ricestockwhynoresponse[451] <- "[amount redacted]"
mydata$s5q56ricestockwhynoresponse[491] <- "[amount redacted] kilos of milled rice"

mydata$s5q57whynoresponse[740] <- "The mother of the 2 grandchildren is the member of the 4Ps. But the 2 children is [situation]"
mydata$s5q57whynoresponse[1237] <- "The member of the 4ps is [name] son of [name] she is the one who attended all the meetings of 4ps every now and then. [name] is not member of the roster because he is only once or every another month going back home."

mydata$s5q60whynoresponse[712] <- "He is not sure if it is more than [amount redacted] per 2 months, his wife knows"

mydata$s5q62whynoresponse[932] <- "It was stopped because they were transferred here in [site], [province] since 2012"

mydata$s5q65other[1083] <- "[Tagalog]"
mydata$s5q65other[1694] <- "[Tagalog]"
mydata$s5q65other[1812] <- "[Tagalog]"

GPS data: Displace

# !!!No GPS data

Save processed data in Stata and SPSS format

haven::write_dta(mydata, paste0(filename, "_PU.dta"))
haven::write_sav(mydata, paste0(filename, "_PU.sav"))

# Add report title dynamically
title_var <- paste0("DOL-ILAB SDC - ", filename)