rm(list=ls(all=t))

Setup filenames

filename <- "Section_9" # !!!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. 


# Top code high income to the 99.5 percentile

percentile_99.5 <- floor(quantile(na.exclude(mydata$s9q1)[na.exclude(mydata$s9q1)!=999999], probs = c(0.995)))
mydata <- top_recode (variable="s9q1", break_point=percentile_99.5, missing=999999)
## [1] "Frequency table before encoding"
## s9q1. In the last 7 days how much did the household spend on Bread and Cereals ?  Sa n
##    0   12   17   20   24   25   26   30   35   36   37   38   40   45   50   53   54   60   67   68   70   72 
##   15    2    1    4    2    1    1    4    2    2    1    1    7    2   15    1    2    5    1    2    6    1 
##   75   80   87   88   90   98  100  104  105  108  110  112  114  115  116  118  126  128  132  135  138  140 
##    1    4    1    1    1    1   28    1    2    2    1    1    1    1    1    1    1    2    1    1    1   10 
##  144  145  147  148  150  152  155  157  158  160  162  164  165  166  168  170  171  175  176  180  183  185 
##    1    1    1    1   31    1    2    1    1    8    2    1    3    1    3    2    1    3    2    5    1    2 
##  188  189  190  195  196  199  200  202  205  210  214  215  216  218  220  222  224  225  226  230  231  235 
##    1    1    4    3    1    1   56    2    1   12    1    4    1    1    3    1    9    1    3    7    3    2 
##  236  237  238  239  240  242  245  246  248  250  251  252  254  255  256  258  259  260  264  265  266  267 
##    1    1    2    1   13    3   12    1    3   17    2    4    1    3    1    2    2    5    2    3    5    1 
##  270  273  276  277  279  280  281  282  284  285  288  290  292  293  294  295  300  301  302  304  305  306 
##    7    1    1    1    1   16    2    2    2    1    3    2    1    1    4    2   61    4    2    1    2    2 
##  307  308  309  310  312  315  316  317  318  320  322  324  325  328  329  330  334  335  336  337  339  340 
##    1    4    2    6    3    8    2    1    1    9    2    2    1    2    1    9    1    2    5    2    1   11 
##  344  345  346  348  349  350  351  352  354  355  356  357  359  360  364  365  366  367  368  369  370  371 
##    1    3    3    1    2   45    2    1    2    4    1    4    1    8    7    1    1    2    6    1    6    2 
##  372  373  376  377  378  380  383  384  385  386  387  388  390  392  395  397  398  399  400  401  402  403 
##    2    1    1    1   11   15    2    3    7    1    2    1    3    6    2    1    1    2   44    1    1    1 
##  404  406  408  409  410  412  413  415  416  417  418  420  422  424  425  427  429  430  431  432  434  435 
##    3    1    2    1    4    1    2    1    1    2    1   31    1    1    4    1    1    6    1    2    5    1 
##  436  438  440  442  446  447  448  449  450  452  455  456  460  462  464  466  467  468  469  470  474  475 
##    2    4    7    1    1    1   15    1   26    1   11    2   11    3    1    4    2    1    1    5    1    5 
##  476  478  480  481  483  484  485  486  487  488  490  493  495  496  498  500  501  502  504  505  506  508 
##    7    2   13    1    2    1    1    1    2    2   30    1    2    1    3  113    2    1   15    1    2    6 
##  510  515  517  518  520  522  523  524  525  526  528  529  530  532  534  536  537  540  544  545  546  550 
##   12    1    1   10    9    1    2    2   12    2    1    1    6    9    2    3    1    7    2    2    4   10 
##  552  553  554  555  556  560  564  567  569  570  572  574  575  577  578  579  580  582  583  584  585  588 
##    2    1    1    2    1   34    4    3    1    5    1    5    4    1    4    1    1    3    1    5    3    7 
##  590  592  595  596  599  600  602  604  605  606  608  609  610  611  612  613  615  616  617  620  624  625 
##    6    1    8    3    1   28    2    2    1    1    1    1    6    1    3    1    1    3    1    4    2    1 
##  627  630  632  635  636  639  640  644  645  647  650  651  652  654  655  656  658  660  661  662  665  666 
##    1   28    3    2    1    1    8   11    2    1   12    5    1    1    1    1    3    8    1    3    4    1 
##  668  670  672  674  675  676  677  678  679  680  685  686  688  689  690  692  693  695  696  700  702  704 
##    2    3   16    1    2    1    1    1    1    4    1    2    2    2    3    1    4    1    1   79    1    1 
##  705  707  708  710  714  715  720  722  725  726  728  730  731  732  733  735  737  738  740  741  742  745 
##    2    2    1    1    6    1    6    2    1    1    3    2    1    2    1   23    1    1    7    1    5    1 
##  746  749  750  752  754  755  756  760  766  770  774  775  777  779  780  782  784  785  788  789  790  791 
##    1    1   15    3    1    3    9    1    1   18    1    1    3    1    5    1    3    3    1    1    3    3 
##  792  793  794  795  797  798  800  803  805  806  808  810  812  816  819  820  821  823  825  826  827  829 
##    1    2    1    1    1    9   27    1    5    1    1    2    3    1    3    1    1    1    2    2    1    2 
##  830  833  834  835  840  842  843  850  851  854  855  860  861  868  870  872  875  876  880  882  884  890 
##    1    2    2    1   33    1    1    8    1    2    1    2    1    1    2    1    6    1    2    8    1    2 
##  892  896  898  900  903  910  915  920  925  928  929  930  931  938  940  945  948  950  955  960  962  965 
##    1    1    1   11    2    6    1    2    1    1    1    3    1    2    1    6    1    2    1    2    1    1 
##  966  970  976  980  987  988  995  996  997  998 1000 1007 1008 1015 1016 1020 1022 1029 1036 1040 1043 1050 
##    2    1    1    7    2    1    1    1    1    1   36    1    2    3    1    2    1    1    1    5    1   15 
## 1058 1060 1064 1068 1070 1071 1075 1080 1085 1088 1092 1100 1106 1110 1115 1119 1120 1128 1134 1145 1148 1155 
##    1    1    2    1    1    1    1    2    2    1    1    3    1    1    1    1    5    1    2    1    1    1 
## 1162 1170 1173 1176 1190 1193 1200 1218 1221 1225 1230 1240 1260 1275 1300 1323 1325 1330 1339 1358 1360 1372 
##    2    1    1    2    2    1   14    1    1    1    1    1    4    1    3    1    1    3    1    2    2    1 
## 1386 1400 1410 1424 1438 1448 1500 1554 1568 1584 1600 1610 1626 1680 1700 1720 1736 1848 1850 1890 1892 2000 
##    1   14    1    1    1    1   12    1    1    1    1    1    1    1    1    1    1    1    1    1    1    4 
## 2016 2050 2072 2100 2138 2380 2700 2738 3004 3720 3880 4000 <NA> 
##    1    1    1    3    1    1    1    1    1    1    1    2    6

## [1] "Frequency table after encoding"
## s9q1. In the last 7 days how much did the household spend on Bread and Cereals ?  Sa n
##            0           12           17           20           24           25           26           30 
##           15            2            1            4            2            1            1            4 
##           35           36           37           38           40           45           50           53 
##            2            2            1            1            7            2           15            1 
##           54           60           67           68           70           72           75           80 
##            2            5            1            2            6            1            1            4 
##           87           88           90           98          100          104          105          108 
##            1            1            1            1           28            1            2            2 
##          110          112          114          115          116          118          126          128 
##            1            1            1            1            1            1            1            2 
##          132          135          138          140          144          145          147          148 
##            1            1            1           10            1            1            1            1 
##          150          152          155          157          158          160          162          164 
##           31            1            2            1            1            8            2            1 
##          165          166          168          170          171          175          176          180 
##            3            1            3            2            1            3            2            5 
##          183          185          188          189          190          195          196          199 
##            1            2            1            1            4            3            1            1 
##          200          202          205          210          214          215          216          218 
##           56            2            1           12            1            4            1            1 
##          220          222          224          225          226          230          231          235 
##            3            1            9            1            3            7            3            2 
##          236          237          238          239          240          242          245          246 
##            1            1            2            1           13            3           12            1 
##          248          250          251          252          254          255          256          258 
##            3           17            2            4            1            3            1            2 
##          259          260          264          265          266          267          270          273 
##            2            5            2            3            5            1            7            1 
##          276          277          279          280          281          282          284          285 
##            1            1            1           16            2            2            2            1 
##          288          290          292          293          294          295          300          301 
##            3            2            1            1            4            2           61            4 
##          302          304          305          306          307          308          309          310 
##            2            1            2            2            1            4            2            6 
##          312          315          316          317          318          320          322          324 
##            3            8            2            1            1            9            2            2 
##          325          328          329          330          334          335          336          337 
##            1            2            1            9            1            2            5            2 
##          339          340          344          345          346          348          349          350 
##            1           11            1            3            3            1            2           45 
##          351          352          354          355          356          357          359          360 
##            2            1            2            4            1            4            1            8 
##          364          365          366          367          368          369          370          371 
##            7            1            1            2            6            1            6            2 
##          372          373          376          377          378          380          383          384 
##            2            1            1            1           11           15            2            3 
##          385          386          387          388          390          392          395          397 
##            7            1            2            1            3            6            2            1 
##          398          399          400          401          402          403          404          406 
##            1            2           44            1            1            1            3            1 
##          408          409          410          412          413          415          416          417 
##            2            1            4            1            2            1            1            2 
##          418          420          422          424          425          427          429          430 
##            1           31            1            1            4            1            1            6 
##          431          432          434          435          436          438          440          442 
##            1            2            5            1            2            4            7            1 
##          446          447          448          449          450          452          455          456 
##            1            1           15            1           26            1           11            2 
##          460          462          464          466          467          468          469          470 
##           11            3            1            4            2            1            1            5 
##          474          475          476          478          480          481          483          484 
##            1            5            7            2           13            1            2            1 
##          485          486          487          488          490          493          495          496 
##            1            1            2            2           30            1            2            1 
##          498          500          501          502          504          505          506          508 
##            3          113            2            1           15            1            2            6 
##          510          515          517          518          520          522          523          524 
##           12            1            1           10            9            1            2            2 
##          525          526          528          529          530          532          534          536 
##           12            2            1            1            6            9            2            3 
##          537          540          544          545          546          550          552          553 
##            1            7            2            2            4           10            2            1 
##          554          555          556          560          564          567          569          570 
##            1            2            1           34            4            3            1            5 
##          572          574          575          577          578          579          580          582 
##            1            5            4            1            4            1            1            3 
##          583          584          585          588          590          592          595          596 
##            1            5            3            7            6            1            8            3 
##          599          600          602          604          605          606          608          609 
##            1           28            2            2            1            1            1            1 
##          610          611          612          613          615          616          617          620 
##            6            1            3            1            1            3            1            4 
##          624          625          627          630          632          635          636          639 
##            2            1            1           28            3            2            1            1 
##          640          644          645          647          650          651          652          654 
##            8           11            2            1           12            5            1            1 
##          655          656          658          660          661          662          665          666 
##            1            1            3            8            1            3            4            1 
##          668          670          672          674          675          676          677          678 
##            2            3           16            1            2            1            1            1 
##          679          680          685          686          688          689          690          692 
##            1            4            1            2            2            2            3            1 
##          693          695          696          700          702          704          705          707 
##            4            1            1           79            1            1            2            2 
##          708          710          714          715          720          722          725          726 
##            1            1            6            1            6            2            1            1 
##          728          730          731          732          733          735          737          738 
##            3            2            1            2            1           23            1            1 
##          740          741          742          745          746          749          750          752 
##            7            1            5            1            1            1           15            3 
##          754          755          756          760          766          770          774          775 
##            1            3            9            1            1           18            1            1 
##          777          779          780          782          784          785          788          789 
##            3            1            5            1            3            3            1            1 
##          790          791          792          793          794          795          797          798 
##            3            3            1            2            1            1            1            9 
##          800          803          805          806          808          810          812          816 
##           27            1            5            1            1            2            3            1 
##          819          820          821          823          825          826          827          829 
##            3            1            1            1            2            2            1            2 
##          830          833          834          835          840          842          843          850 
##            1            2            2            1           33            1            1            8 
##          851          854          855          860          861          868          870          872 
##            1            2            1            2            1            1            2            1 
##          875          876          880          882          884          890          892          896 
##            6            1            2            8            1            2            1            1 
##          898          900          903          910          915          920          925          928 
##            1           11            2            6            1            2            1            1 
##          929          930          931          938          940          945          948          950 
##            1            3            1            2            1            6            1            2 
##          955          960          962          965          966          970          976          980 
##            1            2            1            1            2            1            1            7 
##          987          988          995          996          997          998         1000         1007 
##            2            1            1            1            1            1           36            1 
##         1008         1015         1016         1020         1022         1029         1036         1040 
##            2            3            1            2            1            1            1            5 
##         1043         1050         1058         1060         1064         1068         1070         1071 
##            1           15            1            1            2            1            1            1 
##         1075         1080         1085         1088         1092         1100         1106         1110 
##            1            2            2            1            1            3            1            1 
##         1115         1119         1120         1128         1134         1145         1148         1155 
##            1            1            5            1            2            1            1            1 
##         1162         1170         1173         1176         1190         1193         1200         1218 
##            2            1            1            2            2            1           14            1 
##         1221         1225         1230         1240         1260         1275         1300         1323 
##            1            1            1            1            4            1            3            1 
##         1325         1330         1339         1358         1360         1372         1386         1400 
##            1            3            1            2            2            1            1           14 
##         1410         1424         1438         1448         1500         1554         1568         1584 
##            1            1            1            1           12            1            1            1 
##         1600         1610         1626         1680         1700         1720         1736         1848 
##            1            1            1            1            1            1            1            1 
##         1850         1890         1892         2000         2016         2050         2072 2087 or more 
##            1            1            1            4            1            1            1           12 
##         <NA> 
##            6

percentile_99.5 <- floor(quantile(na.exclude(mydata$s9q2)[na.exclude(mydata$s9q2)!=999999], probs = c(0.995)))
mydata <- top_recode (variable="s9q2", break_point=percentile_99.5, missing=999999)
## [1] "Frequency table before encoding"
## s9q2. In the last 7 days how much did the household spend on Roots and tubers  ?  Sa n
##    0    5    7   10   11   12   13   14   15   16   17   18   20   22   23   24   25   26   28   30   35   36 
##  515    5    1   45    1    2    1    1   36    1    1    1  204    2    1    2   34    2    1   73   17    2 
##   39   40   44   45   48   50   52   55   56   60   63   68   70   75   80   84   90  100  105  116  120  140 
##    1   48    1    4    1   90    1    2    2   33    1    1    6    2    9    1    3   70    2    1   13   12 
##  150  160  175  200  210  245  250  280  300  450  500  530  700 1000 <NA> 
##   17    1    1   30    1    1    3    1    6    1    3    1    1    1  976

## [1] "Frequency table after encoding"
## s9q2. In the last 7 days how much did the household spend on Roots and tubers  ?  Sa n
##           0           5           7          10          11          12          13          14          15 
##         515           5           1          45           1           2           1           1          36 
##          16          17          18          20          22          23          24          25          26 
##           1           1           1         204           2           1           2          34           2 
##          28          30          35          36          39          40          44          45          48 
##           1          73          17           2           1          48           1           4           1 
##          50          52          55          56          60          63          68          70          75 
##          90           1           2           2          33           1           1           6           2 
##          80          84          90         100         105         116         120         140         150 
##           9           1           3          70           2           1          13          12          17 
##         160         175         200         210         245         250         280         300 360 or more 
##           1           1          30           1           1           3           1           6           7 
##        <NA> 
##         976

percentile_99.5 <- floor(quantile(na.exclude(mydata$s9q3)[na.exclude(mydata$s9q3)!=999999], probs = c(0.995)))
mydata <- top_recode (variable="s9q3", break_point=percentile_99.5, missing=999999)
## [1] "Frequency table before encoding"
## s9q3. In the last 7 days how much did the household spend on Vegetables ?  Sa nakalipa
##    0    5    8    9   10   11   12   14   15   16   20   22   24   25   27   28   30   32   35   36   40   41 
##  491    9    2    1   38    2    2    2   30    1  109    1    1   26    3    1  110    1   18    1   61    1 
##   42   43   44   45   47   50   55   58   60   65   66   70   75   77   80   81   85   88   90  100  101  105 
##    3    1    1   17    1  240    9    1   49    4    1   43    5    1   34    1    1    1   15  261    1   14 
##  110  118  120  122  125  126  133  135  140  145  150  160  165  170  175  180  185  200  210  220  245  250 
##    1    1   21    2    1    1    1    1   29    1  105    4    1    2    4    4    1  153   21    1    2   19 
##  260  280  300  315  350  360  370  400  420  490  500  550  560  600  700  800 1050 1400 2180 <NA> 
##    1   10   82    1   16    1    1   10    3    1   23    1    2    1   11    1    3    1    1  135

## [1] "Frequency table after encoding"
## s9q3. In the last 7 days how much did the household spend on Vegetables ?  Sa nakalipa
##           0           5           8           9          10          11          12          14          15 
##         491           9           2           1          38           2           2           2          30 
##          16          20          22          24          25          27          28          30          32 
##           1         109           1           1          26           3           1         110           1 
##          35          36          40          41          42          43          44          45          47 
##          18           1          61           1           3           1           1          17           1 
##          50          55          58          60          65          66          70          75          77 
##         240           9           1          49           4           1          43           5           1 
##          80          81          85          88          90         100         101         105         110 
##          34           1           1           1          15         261           1          14           1 
##         118         120         122         125         126         133         135         140         145 
##           1          21           2           1           1           1           1          29           1 
##         150         160         165         170         175         180         185         200         210 
##         105           4           1           2           4           4           1         153          21 
##         220         245         250         260         280         300         315         350         360 
##           1           2          19           1          10          82           1          16           1 
##         370         400         420         490         500         550         560         600 700 or more 
##           1          10           3           1          23           1           2           1          17 
##        <NA> 
##         135

percentile_99.5 <- floor(quantile(na.exclude(mydata$s9q4)[na.exclude(mydata$s9q4)!=999999], probs = c(0.995)))
mydata <- top_recode (variable="s9q4", break_point=percentile_99.5, missing=999999)
## [1] "Frequency table before encoding"
## s9q4. In the last 7 days how much did the household spend on Meat ?  Sa nakalipas na p
##    0    5   20   25   30   31   32   33   35   37   40   44   45   48   50   55   60   64   65   70   72   74 
##   76    1    8    3    2    1    1    1    3    1    7    1   11    1   44    2   15    1    1   23    1    1 
##   75   80   84   85   86   87   90   91   95   99  100  105  109  110  117  120  122  128  130  135  140  150 
##   26   35    1    8    1    1   48    1   12    1  140    4    1   12    1   25    1    2   15    3   28   88 
##  155  160  164  165  170  171  175  176  180  185  188  190  195  200  202  210  220  224  225  230  240  245 
##    1   64    1    4   48    1    6    1  208    5    1   64    3  224    1   10   17    1    3    4   11    1 
##  250  260  270  273  275  280  290  300  310  315  320  325  330  334  340  345  350  360  370  380  395  400 
##   32    6    5    1    1    6    2   85    1    2   14    1    6    1   13    1   17   41    4    7    1   42 
##  415  420  430  435  440  450  455  458  480  490  500  508  510  520  525  530  540  550  554  570  580  600 
##    1    1    2    1    1    8    1    1    3    1   48    1    8    2    1    1   15    2    1    3    1   19 
##  620  630  640  680  700  738  750  760  800  820  840  850  900  990 1000 1200 1295 1400 1500 1540 1800 2000 
##    1    2    2    3   11    1    1    1    3    2    1    1    2    1    7    1    1    1    1    1    1    1 
## 2240 2520 2700 3000 <NA> 
##    1    1    1    2  496

## [1] "Frequency table after encoding"
## s9q4. In the last 7 days how much did the household spend on Meat ?  Sa nakalipas na p
##            0            5           20           25           30           31           32           33 
##           76            1            8            3            2            1            1            1 
##           35           37           40           44           45           48           50           55 
##            3            1            7            1           11            1           44            2 
##           60           64           65           70           72           74           75           80 
##           15            1            1           23            1            1           26           35 
##           84           85           86           87           90           91           95           99 
##            1            8            1            1           48            1           12            1 
##          100          105          109          110          117          120          122          128 
##          140            4            1           12            1           25            1            2 
##          130          135          140          150          155          160          164          165 
##           15            3           28           88            1           64            1            4 
##          170          171          175          176          180          185          188          190 
##           48            1            6            1          208            5            1           64 
##          195          200          202          210          220          224          225          230 
##            3          224            1           10           17            1            3            4 
##          240          245          250          260          270          273          275          280 
##           11            1           32            6            5            1            1            6 
##          290          300          310          315          320          325          330          334 
##            2           85            1            2           14            1            6            1 
##          340          345          350          360          370          380          395          400 
##           13            1           17           41            4            7            1           42 
##          415          420          430          435          440          450          455          458 
##            1            1            2            1            1            8            1            1 
##          480          490          500          508          510          520          525          530 
##            3            1           48            1            8            2            1            1 
##          540          550          554          570          580          600          620          630 
##           15            2            1            3            1           19            1            2 
##          640          680          700          738          750          760          800          820 
##            2            3           11            1            1            1            3            2 
##          840          850          900          990         1000         1200         1295 1400 or more 
##            1            1            2            1            7            1            1           10 
##         <NA> 
##          496

percentile_99.5 <- floor(quantile(na.exclude(mydata$s9q5)[na.exclude(mydata$s9q5)!=999999], probs = c(0.995)))
mydata <- top_recode (variable="s9q5", break_point=percentile_99.5, missing=999999)
## [1] "Frequency table before encoding"
## s9q5. In the last 7 days how much did the household spend on Fish?  Sa nakalipas na pi
##    0    5   10   12   15   16   17   20   25   28   30   32   34   35   36   38   40   42   45   48   50   53 
##  300    1    2    2    2    2    2   10    8    1   19    1    1   11    3    1   30    1    6    1   70    1 
##   54   55   58   59   60   64   65   70   75   80   85   89   90   95   96  100  105  106  108  110  114  115 
##    1    4    1    1   70    1   12   50   17   49    3    1   28    3    2  215    2    1    1   13    1    1 
##  118  119  120  124  126  130  134  135  139  140  142  145  150  154  155  156  157  160  165  170  174  175 
##    1    2  131    1    1   34    1    4    2   32    1    3  105    1    2    2    3   32    1    4    2    1 
##  178  180  181  184  185  190  193  194  195  198  199  200  202  204  208  210  212  220  225  228  230  231 
##    1   38    1    1    3    9    1    1    1    3    1  163    2    1    1   21    1   12    1    1    5    1 
##  240  244  245  250  260  261  267  269  270  272  275  280  281  285  286  290  296  297  300  310  315  320 
##   42    2    1   32   13    1    1    1    8    1    1   21    1    2    1    3    1    1  144    1    1    5 
##  330  334  340  345  350  352  355  360  370  375  380  385  390  395  400  410  420  424  428  430  444  450 
##    6    1    2    1   35    1    1   26    3    1    1    1    3    1   36    1   19    1    1    2    1    4 
##  455  478  480  490  500  520  525  530  550  560  600  618  624  630  640  680  700  720  770  840  900  945 
##    1    1    6    7   41    2    4    1    1    6    9    1    1    1    1    1   15    2    1   10    2    1 
##  990 1000 1050 1260 1400 3254 <NA> 
##    1    3    1    1    1    1  154

## [1] "Frequency table after encoding"
## s9q5. In the last 7 days how much did the household spend on Fish?  Sa nakalipas na pi
##           0           5          10          12          15          16          17          20          25 
##         300           1           2           2           2           2           2          10           8 
##          28          30          32          34          35          36          38          40          42 
##           1          19           1           1          11           3           1          30           1 
##          45          48          50          53          54          55          58          59          60 
##           6           1          70           1           1           4           1           1          70 
##          64          65          70          75          80          85          89          90          95 
##           1          12          50          17          49           3           1          28           3 
##          96         100         105         106         108         110         114         115         118 
##           2         215           2           1           1          13           1           1           1 
##         119         120         124         126         130         134         135         139         140 
##           2         131           1           1          34           1           4           2          32 
##         142         145         150         154         155         156         157         160         165 
##           1           3         105           1           2           2           3          32           1 
##         170         174         175         178         180         181         184         185         190 
##           4           2           1           1          38           1           1           3           9 
##         193         194         195         198         199         200         202         204         208 
##           1           1           1           3           1         163           2           1           1 
##         210         212         220         225         228         230         231         240         244 
##          21           1          12           1           1           5           1          42           2 
##         245         250         260         261         267         269         270         272         275 
##           1          32          13           1           1           1           8           1           1 
##         280         281         285         286         290         296         297         300         310 
##          21           1           2           1           3           1           1         144           1 
##         315         320         330         334         340         345         350         352         355 
##           1           5           6           1           2           1          35           1           1 
##         360         370         375         380         385         390         395         400         410 
##          26           3           1           1           1           3           1          36           1 
##         420         424         428         430         444         450         455         478         480 
##          19           1           1           2           1           4           1           1           6 
##         490         500         520         525         530         550         560         600         618 
##           7          41           2           4           1           1           6           9           1 
##         624         630         640         680         700         720         770         840 857 or more 
##           1           1           1           1          15           2           1          10          11 
##        <NA> 
##         154

percentile_99.5 <- floor(quantile(na.exclude(mydata$s9q6)[na.exclude(mydata$s9q6)!=999999], probs = c(0.995)))
mydata <- top_recode (variable="s9q6", break_point=percentile_99.5, missing=999999)
## [1] "Frequency table before encoding"
## s9q6. In the last 7 days how much did the household spend on Dairy products and eggs ?
##    0    3    6    8   10   12   13   14   15   18   19   20   21   22   24   25   26   27   28   30   31   32 
##   80    1    3    1    2   20    3   18    8   22    1   51   39    1   40   15    1    3   30   96    1    2 
##   34   35   36   38   39   40   41   42   43   45   48   49   50   51   52   53   54   55   56   58   59   60 
##    1   41   47    3    1   17    1   48    2    6   16   12  126    1    5    2    9    4   13    2    2   87 
##   61   62   63   64   65   66   67   68   69   70   71   72   75   76   78   79   80   81   82   83   84   85 
##    1    1   10    5    5    8    1    3    1   41    2   32   14    2    4    2   17    1    1    2   34    5 
##   86   87   88   90   91   92   93   94   95   96   97   98   99  100  101  102  104  105  106  107  108  109 
##    3    3    3   22    4    2    1    1    4    8    1    6    2  106    3    2    3   13    1    4    4    2 
##  110  111  112  113  114  115  116  118  120  123  124  125  126  127  128  129  130  131  133  134  135  137 
##    8    1    4    1    3    4    1    1   25    1    2    6   13    2    1    2    6    1    1    1    3    1 
##  138  140  141  142  144  145  146  147  149  150  153  155  156  157  158  159  160  162  164  165  167  168 
##    2   21    3    3    5    3    2   13    2   53    2    2    1    2    1    2    7    1    1    2    1   10 
##  170  174  175  176  177  178  179  180  183  184  185  189  190  191  193  194  195  196  197  199  200  203 
##    4    1    1    2    1    1    2   11    2    1    2    1    3    1    1    2    1    3    1    1   65    1 
##  206  209  210  211  215  217  220  221  222  223  224  225  226  227  228  230  231  232  234  235  236  238 
##    1    1   18    1    1    1    3    1    1    2    1    3    1    1    2    4    2    1    1    2    2    2 
##  240  241  242  244  245  246  248  250  251  252  255  259  260  262  264  265  268  270  274  275  276  278 
##    1    1    3    1    4    1    1   12    1    5    1    2    2    1    3    1    1    3    1    1    1    1 
##  280  282  285  287  288  290  294  297  300  302  306  307  308  309  310  315  316  318  320  326  329  330 
##    4    1    1    1    1    2    2    1   32    1    1    1    1    1    1    2    1    1    2    1    1    3 
##  337  338  340  343  345  350  355  357  360  365  371  372  374  375  376  381  385  386  392  396  400  402 
##    2    1    1    1    1   14    1    2    1    1    1    2    1    2    1    1    2    1    1    1    7    1 
##  406  415  416  420  422  430  434  450  454  456  460  485  500  520  524  542  548  550  556  564  570  575 
##    1    1    1    6    1    2    1    2    1    2    1    1   22    1    1    1    1    1    1    1    1    1 
##  580  600  602  605  616  650  660  665  680  686  698  700  710  730  731  749  765  780  786  800  805  820 
##    1    4    1    1    1    1    2    1    2    1    1    4    1    1    1    1    1    1    1    3    1    1 
##  823  850  900  910  917  949  950  958 1000 1060 1125 2000 <NA> 
##    1    2    2    1    1    1    1    1    3    1    1    1  380

## [1] "Frequency table after encoding"
## s9q6. In the last 7 days how much did the household spend on Dairy products and eggs ?
##           0           3           6           8          10          12          13          14          15 
##          80           1           3           1           2          20           3          18           8 
##          18          19          20          21          22          24          25          26          27 
##          22           1          51          39           1          40          15           1           3 
##          28          30          31          32          34          35          36          38          39 
##          30          96           1           2           1          41          47           3           1 
##          40          41          42          43          45          48          49          50          51 
##          17           1          48           2           6          16          12         126           1 
##          52          53          54          55          56          58          59          60          61 
##           5           2           9           4          13           2           2          87           1 
##          62          63          64          65          66          67          68          69          70 
##           1          10           5           5           8           1           3           1          41 
##          71          72          75          76          78          79          80          81          82 
##           2          32          14           2           4           2          17           1           1 
##          83          84          85          86          87          88          90          91          92 
##           2          34           5           3           3           3          22           4           2 
##          93          94          95          96          97          98          99         100         101 
##           1           1           4           8           1           6           2         106           3 
##         102         104         105         106         107         108         109         110         111 
##           2           3          13           1           4           4           2           8           1 
##         112         113         114         115         116         118         120         123         124 
##           4           1           3           4           1           1          25           1           2 
##         125         126         127         128         129         130         131         133         134 
##           6          13           2           1           2           6           1           1           1 
##         135         137         138         140         141         142         144         145         146 
##           3           1           2          21           3           3           5           3           2 
##         147         149         150         153         155         156         157         158         159 
##          13           2          53           2           2           1           2           1           2 
##         160         162         164         165         167         168         170         174         175 
##           7           1           1           2           1          10           4           1           1 
##         176         177         178         179         180         183         184         185         189 
##           2           1           1           2          11           2           1           2           1 
##         190         191         193         194         195         196         197         199         200 
##           3           1           1           2           1           3           1           1          65 
##         203         206         209         210         211         215         217         220         221 
##           1           1           1          18           1           1           1           3           1 
##         222         223         224         225         226         227         228         230         231 
##           1           2           1           3           1           1           2           4           2 
##         232         234         235         236         238         240         241         242         244 
##           1           1           2           2           2           1           1           3           1 
##         245         246         248         250         251         252         255         259         260 
##           4           1           1          12           1           5           1           2           2 
##         262         264         265         268         270         274         275         276         278 
##           1           3           1           1           3           1           1           1           1 
##         280         282         285         287         288         290         294         297         300 
##           4           1           1           1           1           2           2           1          32 
##         302         306         307         308         309         310         315         316         318 
##           1           1           1           1           1           1           2           1           1 
##         320         326         329         330         337         338         340         343         345 
##           2           1           1           3           2           1           1           1           1 
##         350         355         357         360         365         371         372         374         375 
##          14           1           2           1           1           1           2           1           2 
##         376         381         385         386         392         396         400         402         406 
##           1           1           2           1           1           1           7           1           1 
##         415         416         420         422         430         434         450         454         456 
##           1           1           6           1           2           1           2           1           2 
##         460         485         500         520         524         542         548         550         556 
##           1           1          22           1           1           1           1           1           1 
##         564         570         575         580         600         602         605         616         650 
##           1           1           1           1           4           1           1           1           1 
##         660         665         680         686         698         700         710         730         731 
##           2           1           2           1           1           4           1           1           1 
##         749         765         780         786         800         805         820         823         850 
##           1           1           1           1           3           1           1           1           2 
##         900         910 912 or more        <NA> 
##           2           1          10         380

percentile_99.5 <- floor(quantile(na.exclude(mydata$s9q7)[na.exclude(mydata$s9q7)!=999999], probs = c(0.995)))
mydata <- top_recode (variable="s9q7", break_point=percentile_99.5, missing=999999)
## [1] "Frequency table before encoding"
## s9q7. In the last 7 days how much did the household spend on Oils and fats ?  Sa nakal
##    0    3    5    6    7    8    9   10   11   12   13   14   15   16   17   18   19   20   21   22   23   24 
##   28    3   26    2    4    2    3   77    4   19   12   24  116   39   40   77   11  308   15   32   20   36 
##   25   26   27   28   29   30   31   32   33   34   35   36   38   40   41   42   43   44   45   46   47   48 
##  100   31   16   38    2  187    1   48    3   26   69   42    9  146    1   12    5   17   33    5    2   32 
##   50   51   52   53   54   55   56   58   59   60   62   63   64   65   66   68   69   70   72   75   76   80 
##  112    6   15    2   21    3    7    3    1  102    2    2    3    4    8    2    2   37    9   13    2   21 
##   81   83   84   85   89   90   91   93   98  100  105  110  111  113  119  120  129  130  132  140  144  150 
##    1    1    2    4    2   26    1    1    1   52    7    2    1    1    1    7    1    1    1    1    1    8 
##  156  160  168  175  179  180  195  200  230  245  280  300  315  640  710  875 1120 <NA> 
##    1    4    1    1    1    2    1   11    1    1    1    3    1    1    1    1    1   40

## [1] "Frequency table after encoding"
## s9q7. In the last 7 days how much did the household spend on Oils and fats ?  Sa nakal
##           0           3           5           6           7           8           9          10          11 
##          28           3          26           2           4           2           3          77           4 
##          12          13          14          15          16          17          18          19          20 
##          19          12          24         116          39          40          77          11         308 
##          21          22          23          24          25          26          27          28          29 
##          15          32          20          36         100          31          16          38           2 
##          30          31          32          33          34          35          36          38          40 
##         187           1          48           3          26          69          42           9         146 
##          41          42          43          44          45          46          47          48          50 
##           1          12           5          17          33           5           2          32         112 
##          51          52          53          54          55          56          58          59          60 
##           6          15           2          21           3           7           3           1         102 
##          62          63          64          65          66          68          69          70          72 
##           2           2           3           4           8           2           2          37           9 
##          75          76          80          81          83          84          85          89          90 
##          13           2          21           1           1           2           4           2          26 
##          91          93          98         100         105         110         111         113         119 
##           1           1           1          52           7           2           1           1           1 
##         120         129         130         132         140         144         150         156         160 
##           7           1           1           1           1           1           8           1           4 
##         168         175         179         180         195 200 or more        <NA> 
##           1           1           1           2           1          22          40

percentile_99.5 <- floor(quantile(na.exclude(mydata$s9q8)[na.exclude(mydata$s9q8)!=999999], probs = c(0.995)))
mydata <- top_recode (variable="s9q8", break_point=percentile_99.5, missing=999999)
## [1] "Frequency table before encoding"
## s9q8. In the last 7 days how much did the household spend on Fruits ?  Sa nakalipas na
##    0    5   10   12   15   16   18   20   24   25   28   30   35   40   43   45   50   55   56   58   60   65 
##  467    2   22    2   21    1    1   78    1   49    1   78   28   71    1   12  144    1    1    1   48    2 
##   70   72   75   80   85   90   95   96   97   99  100  105  110  120  130  140  150  160  175  180  200  220 
##   24    1    4   28    3    9    1    1    1    1  109    2    2   11    1    2   32    3    1    3   42    1 
##  230  250  255  260  272  280  290  295  300  315  320  337  350  360  400  410  420  500 1000 1750 2000 <NA> 
##    2    3    1    1    1    2    1    1   15    1    1    1    3    1    1    1    1    5    1    1    1  937

## [1] "Frequency table after encoding"
## s9q8. In the last 7 days how much did the household spend on Fruits ?  Sa nakalipas na
##           0           5          10          12          15          16          18          20          24 
##         467           2          22           2          21           1           1          78           1 
##          25          28          30          35          40          43          45          50          55 
##          49           1          78          28          71           1          12         144           1 
##          56          58          60          65          70          72          75          80          85 
##           1           1          48           2          24           1           4          28           3 
##          90          95          96          97          99         100         105         110         120 
##           9           1           1           1           1         109           2           2          11 
##         130         140         150         160         175         180         200         220         230 
##           1           2          32           3           1           3          42           1           2 
##         250         255         260         272         280         290         295         300         315 
##           3           1           1           1           2           1           1          15           1 
##         320         337         350         360         400         410         420 500 or more        <NA> 
##           1           1           3           1           1           1           1           8         937

percentile_99.5 <- floor(quantile(na.exclude(mydata$s9q9)[na.exclude(mydata$s9q9)!=999999], probs = c(0.995)))
mydata <- top_recode (variable="s9q9", break_point=percentile_99.5, missing=999999)
## [1] "Frequency table before encoding"
## s9q9. In the last 7 days how much did the household spend on Sugar, Jam, honey, sweets
##    0    2    3    5    6    7    8    9   10   11   12   13   14   15   16   17   18   19   20   21   22   23 
##   18    1    1    4    2    2    2    1   20    7   28   40   36   88   17    8   16    2   47    5   41   17 
##   24   25   26   27   28   30   32   33   34   35   36   37   38   39   40   41   42   43   44   45   46   47 
##   66   47   47   11   69  105   22    1   10   26   19    3    7   16   76    3   51   12   35   62   45    3 
##   48   49   50   51   52   53   54   55   56   57   58   59   60   62   63   64   65   66   68   69   70   72 
##   73    2  103    3   29    4    9   10   37    1   10    1   75    3    3    8    8    8    3    9   20    9 
##   73   74   75   76   77   78   80   81   84   85   86   87   88   89   90   91   92   93   94   95   96   97 
##    1    1   16    2    3    6   31    1   28    2    2    1   12    1   25   24   12    1    1    1   14    1 
##   98  100  102  103  104  105  106  110  112  115  116  117  119  120  121  122  123  124  125  126  129  130 
##   30   72    1    1    9   34    1    6   20    1    3    1    5   24    1    1    1    1    2    5    1    4 
##  132  135  138  140  144  148  150  154  155  156  158  160  161  165  168  169  175  179  180  182  189  192 
##    4    3    1    6    6    1   22    2    2    1    1    1    5    1    2    1    2    1    6    2    1    1 
##  196  200  210  211  215  235  240  250  251  260  278  280  300  312  315  322  350  370  400  420  500  526 
##    1   28    4    1    1    1    2    2    1    1    1    1    8    1    1    2    1    1    1    1    6    1 
##  600  720  820  966  985 <NA> 
##    1    1    1    1    1  175

## [1] "Frequency table after encoding"
## s9q9. In the last 7 days how much did the household spend on Sugar, Jam, honey, sweets
##           0           2           3           5           6           7           8           9          10 
##          18           1           1           4           2           2           2           1          20 
##          11          12          13          14          15          16          17          18          19 
##           7          28          40          36          88          17           8          16           2 
##          20          21          22          23          24          25          26          27          28 
##          47           5          41          17          66          47          47          11          69 
##          30          32          33          34          35          36          37          38          39 
##         105          22           1          10          26          19           3           7          16 
##          40          41          42          43          44          45          46          47          48 
##          76           3          51          12          35          62          45           3          73 
##          49          50          51          52          53          54          55          56          57 
##           2         103           3          29           4           9          10          37           1 
##          58          59          60          62          63          64          65          66          68 
##          10           1          75           3           3           8           8           8           3 
##          69          70          72          73          74          75          76          77          78 
##           9          20           9           1           1          16           2           3           6 
##          80          81          84          85          86          87          88          89          90 
##          31           1          28           2           2           1          12           1          25 
##          91          92          93          94          95          96          97          98         100 
##          24          12           1           1           1          14           1          30          72 
##         102         103         104         105         106         110         112         115         116 
##           1           1           9          34           1           6          20           1           3 
##         117         119         120         121         122         123         124         125         126 
##           1           5          24           1           1           1           1           2           5 
##         129         130         132         135         138         140         144         148         150 
##           1           4           4           3           1           6           6           1          22 
##         154         155         156         158         160         161         165         168         169 
##           2           2           1           1           1           5           1           2           1 
##         175         179         180         182         189         192         196         200         210 
##           2           1           6           2           1           1           1          28           4 
##         211         215         235         240         250         251         260         278         280 
##           1           1           1           2           2           1           1           1           1 
##         300         312         315         322         350         370         400         420 500 or more 
##           8           1           1           2           1           1           1           1          12 
##        <NA> 
##         175

percentile_99.5 <- floor(quantile(na.exclude(mydata$s9q10)[na.exclude(mydata$s9q10)!=999999], probs = c(0.995)))
mydata <- top_recode (variable="s9q10", break_point=percentile_99.5, missing=999999)
## [1] "Frequency table before encoding"
## s9q10. In the last 7 days how much did the household spend on Non-alcoholic drinks ?  S
##    0    4    6    8    9   10   11   12   13   14   15   16   17   18   19   20   21   22   23   24   25   26 
##    6    2    4    1    2   14    1    8    4   12    7    2   11   28   14  134   21   33   12   13   66    4 
##   27   28   29   30   31   32   33   34   35   36   37   38   39   40   41   42   43   44   45   46   47   48 
##    4   20    2   50    3    8    5   14   32   24    7   17    3   86    1   26    7   21   15   12    5   14 
##   49   50   51   52   53   54   55   56   57   58   59   60   61   62   63   64   65   66   67   68   69   70 
##   31  154    7    9    2    8    9   16    7    3    4   73    1    5   11    7   10    4    6    6    2   70 
##   71   72   73   74   75   76   77   78   79   80   81   82   83   84   85   86   87   88   89   90   91   92 
##    4    8    3    5   20    6   14    9    6   40    1    4    7   22    6    8    3    6    6   10    1    6 
##   94   95   96   97   98   99  100  102  103  104  105  106  107  108  109  110  111  112  113  114  115  116 
##    5    3    6    2   30    2  153    4    2    5   12    8    3    6    1   10    3    2    1    4    2    4 
##  117  118  119  120  122  123  124  125  126  127  128  129  130  132  133  134  135  138  140  141  142  144 
##    2    4    5   18    4    2    4    2    5    1    5    1    6    2    1    7    2    2   29    2    5    3 
##  145  147  148  150  152  153  154  156  158  159  160  161  162  164  165  166  168  170  172  174  175  176 
##    3   14    4   52    2    1    9    2    3    1    9    1    2    1    2    4    6    4    1    2    6    2 
##  178  180  181  184  185  186  187  189  190  191  193  194  195  196  198  199  200  206  207  208  210  212 
##    2    5    2    3    1    2    1    5    1    1    1    1    1    8    2    1   55    1    1    1    9    2 
##  214  215  217  220  222  223  225  226  229  231  236  238  240  242  245  246  248  250  252  253  256  258 
##    1    3    1    1    1    1    1    1    1    2    2    1    1    1    3    2    1    6    2    1    1    2 
##  260  263  266  273  276  280  285  286  288  290  294  300  304  308  311  313  314  317  320  324  337  338 
##    1    1    2    1    1    7    1    1    1    2    3   23    1    1    1    1    1    1    1    1    1    1 
##  343  350  354  356  360  361  378  400  413  414  420  430  441  490  500  525  539  630  652  665  682  690 
##    1   11    1    1    1    1    1    2    1    1    1    1    1    2    6    1    1    1    1    1    1    1 
##  710  872 1000 <NA> 
##    1    1    1  132

## [1] "Frequency table after encoding"
## s9q10. In the last 7 days how much did the household spend on Non-alcoholic drinks ?  S
##           0           4           6           8           9          10          11          12          13 
##           6           2           4           1           2          14           1           8           4 
##          14          15          16          17          18          19          20          21          22 
##          12           7           2          11          28          14         134          21          33 
##          23          24          25          26          27          28          29          30          31 
##          12          13          66           4           4          20           2          50           3 
##          32          33          34          35          36          37          38          39          40 
##           8           5          14          32          24           7          17           3          86 
##          41          42          43          44          45          46          47          48          49 
##           1          26           7          21          15          12           5          14          31 
##          50          51          52          53          54          55          56          57          58 
##         154           7           9           2           8           9          16           7           3 
##          59          60          61          62          63          64          65          66          67 
##           4          73           1           5          11           7          10           4           6 
##          68          69          70          71          72          73          74          75          76 
##           6           2          70           4           8           3           5          20           6 
##          77          78          79          80          81          82          83          84          85 
##          14           9           6          40           1           4           7          22           6 
##          86          87          88          89          90          91          92          94          95 
##           8           3           6           6          10           1           6           5           3 
##          96          97          98          99         100         102         103         104         105 
##           6           2          30           2         153           4           2           5          12 
##         106         107         108         109         110         111         112         113         114 
##           8           3           6           1          10           3           2           1           4 
##         115         116         117         118         119         120         122         123         124 
##           2           4           2           4           5          18           4           2           4 
##         125         126         127         128         129         130         132         133         134 
##           2           5           1           5           1           6           2           1           7 
##         135         138         140         141         142         144         145         147         148 
##           2           2          29           2           5           3           3          14           4 
##         150         152         153         154         156         158         159         160         161 
##          52           2           1           9           2           3           1           9           1 
##         162         164         165         166         168         170         172         174         175 
##           2           1           2           4           6           4           1           2           6 
##         176         178         180         181         184         185         186         187         189 
##           2           2           5           2           3           1           2           1           5 
##         190         191         193         194         195         196         198         199         200 
##           1           1           1           1           1           8           2           1          55 
##         206         207         208         210         212         214         215         217         220 
##           1           1           1           9           2           1           3           1           1 
##         222         223         225         226         229         231         236         238         240 
##           1           1           1           1           1           2           2           1           1 
##         242         245         246         248         250         252         253         256         258 
##           1           3           2           1           6           2           1           1           2 
##         260         263         266         273         276         280         285         286         288 
##           1           1           2           1           1           7           1           1           1 
##         290         294         300         304         308         311         313         314         317 
##           2           3          23           1           1           1           1           1           1 
##         320         324         337         338         343         350         354         356         360 
##           1           1           1           1           1          11           1           1           1 
##         361         378         400         413         414         420         430         441         490 
##           1           1           2           1           1           1           1           1           2 
## 500 or more        <NA> 
##          16         132

percentile_99.5 <- floor(quantile(na.exclude(mydata$s9q11)[na.exclude(mydata$s9q11)!=999999], probs = c(0.995)))
mydata <- top_recode (variable="s9q11", break_point=percentile_99.5, missing=999999)
## [1] "Frequency table before encoding"
## s9q11. In the last 7 days how much did the household spend on Alcoholic drinks ?  Sa na
##    0    1   10   15   16   17   18   20   21   22   25   27   28   29   30   32   34   35   36   37   38   40 
##  188    1    4    1    1    1    1   16    2    2    9    2    2    1    5    1    1    7    1    3    4   57 
##   42   43   44   45   47   48   49   50   53   60   65   70   75   80   82   84   85   86   88   90   94   95 
##   11    2    5   52    3    5    1   33    1    9    2    7    5   15    1    6    7    1    1   25    2    3 
##  100  105  114  115  120  135  140  145  150  152  160  162  168  170  175  180  182  195  200  210  225  245 
##   76    3    2    1    6    4    1    1   12    2    3    2    2    3    1    4    1    1   24    1    1    1 
##  250  265  280  288  294  300  301  315  320  400  500  700  800  900 1000 1120 1500 2000 <NA> 
##    4    1    4    1    4   15    1    4    1    3    5    1    1    1    2    1    3    2 1583

## [1] "Frequency table after encoding"
## s9q11. In the last 7 days how much did the household spend on Alcoholic drinks ?  Sa na
##            0            1           10           15           16           17           18           20 
##          188            1            4            1            1            1            1           16 
##           21           22           25           27           28           29           30           32 
##            2            2            9            2            2            1            5            1 
##           34           35           36           37           38           40           42           43 
##            1            7            1            3            4           57           11            2 
##           44           45           47           48           49           50           53           60 
##            5           52            3            5            1           33            1            9 
##           65           70           75           80           82           84           85           86 
##            2            7            5           15            1            6            7            1 
##           88           90           94           95          100          105          114          115 
##            1           25            2            3           76            3            2            1 
##          120          135          140          145          150          152          160          162 
##            6            4            1            1           12            2            3            2 
##          168          170          175          180          182          195          200          210 
##            2            3            1            4            1            1           24            1 
##          225          245          250          265          280          288          294          300 
##            1            1            4            1            4            1            4           15 
##          301          315          320          400          500          700          800          900 
##            1            4            1            3            5            1            1            1 
##         1000         1120 1500 or more         <NA> 
##            2            1            5         1583

percentile_99.5 <- floor(quantile(na.exclude(mydata$s9q12)[na.exclude(mydata$s9q12)!=999999], probs = c(0.995)))
mydata <- top_recode (variable="s9q12", break_point=percentile_99.5, missing=999999)
## [1] "Frequency table before encoding"
## s9q12. In the last 7 days how much did the household spend on Tobacco ?  Sa nakalipas n
##    0    3    4    5    6    9   10   12   14   15   16   18   20   21   24   25   26   27   28   30   31   32 
##    3    2    1    5    2    1   18    3    7    5    1    4   34    4    3    7    1    2   10   32    1    1 
##   35   36   37   38   39   40   42   45   49   50   52   53   54   56   58   60   61   63   64   68   70   72 
##   30    2    2    4    1   48   10   13    2   47    2    1    1    6    2   31    1    7    2    2   78    1 
##   75   76   80   81   84   85   86   88   90   93   95   96   98  100  105  108  111  112  114  120  122  123 
##    2    1   33    1    8    1    2    3   17    1    1    1    1   65   26    2    1    4    2   44    1    1 
##  126  128  129  130  132  133  135  140  141  148  150  152  154  160  167  168  170  175  180  181  182  189 
##    3    1    1    1    1    4    4   72    1    1   20    2    4   14    1    1    2   21    2    1    1    2 
##  190  192  196  200  208  210  217  220  224  225  240  245  250  252  259  260  263  266  270  273  280  294 
##    2    1    3   31    1   38    1    1    3    1    2    9    3    2    3    1    1    7    1    3   72    4 
##  300  301  308  315  331  350  360  370  378  380  385  400  420  470  480  490  500  518  532  560  600  602 
##   14    1    1   22    1   18    2    1    1    1    4    2    8    1    1    2    4    1    2    7    1    1 
##  700  770  800  810  840 <NA> 
##    4    1    2    1    3 1181

## [1] "Frequency table after encoding"
## s9q12. In the last 7 days how much did the household spend on Tobacco ?  Sa nakalipas n
##           0           3           4           5           6           9          10          12          14 
##           3           2           1           5           2           1          18           3           7 
##          15          16          18          20          21          24          25          26          27 
##           5           1           4          34           4           3           7           1           2 
##          28          30          31          32          35          36          37          38          39 
##          10          32           1           1          30           2           2           4           1 
##          40          42          45          49          50          52          53          54          56 
##          48          10          13           2          47           2           1           1           6 
##          58          60          61          63          64          68          70          72          75 
##           2          31           1           7           2           2          78           1           2 
##          76          80          81          84          85          86          88          90          93 
##           1          33           1           8           1           2           3          17           1 
##          95          96          98         100         105         108         111         112         114 
##           1           1           1          65          26           2           1           4           2 
##         120         122         123         126         128         129         130         132         133 
##          44           1           1           3           1           1           1           1           4 
##         135         140         141         148         150         152         154         160         167 
##           4          72           1           1          20           2           4          14           1 
##         168         170         175         180         181         182         189         190         192 
##           1           2          21           2           1           1           2           2           1 
##         196         200         208         210         217         220         224         225         240 
##           3          31           1          38           1           1           3           1           2 
##         245         250         252         259         260         263         266         270         273 
##           9           3           2           3           1           1           7           1           3 
##         280         294         300         301         308         315         331         350         360 
##          72           4          14           1           1          22           1          18           2 
##         370         378         380         385         400         420         470         480         490 
##           1           1           1           4           2           8           1           1           2 
##         500         518         532         560         600         602         700         770 782 or more 
##           4           1           2           7           1           1           4           1           6 
##        <NA> 
##        1181

percentile_99.5 <- floor(quantile(na.exclude(mydata$s9q13)[na.exclude(mydata$s9q13)!=999999], probs = c(0.995)))
mydata <- top_recode (variable="s9q13", break_point=percentile_99.5, missing=999999)
## [1] "Frequency table before encoding"
## s9q13. In the last 7 days how much did the household spend on Spices and condiments ?  
##    0    3    4    5    6    7    8    9   10   11   12   13   14   15   16   17   18   20   21   22   23   24 
##   14    1    2    8    3    3    4    4   49    4   13    1    4   27    2    3    4  144    3    2    4    4 
##   25   26   27   28   29   30   31   32   34   35   36   37   38   40   41   42   43   44   45   46   47   48 
##   29    2    3    4    1  131    1    5    2   26    7    2    7   36    6    4    2    1    9    2    1    1 
##   49   50   51   52   53   54   55   56   57   58   60   63   64   65   66   67   68   70   71   73   75   80 
##    1  591    2    2    3    4    6    2    1    4   56    1    1    4    1    2    1   40    1    2    8   26 
##   83   86   90   92   93   95   96  100  102  105  108  110  120  123  125  130  140  150  156  160  170  180 
##    1    1    5    1    2    1    1  502    1    4    2    1   13    1    1    2   11  111    1    2    1    3 
##  200  210  230  233  245  250  270  280  300  320  350  400  490  500  700 1000 2000 <NA> 
##  137    1    1    1    1   13    1    1   65    1    7    4    1   15    2    1    1   31

## [1] "Frequency table after encoding"
## s9q13. In the last 7 days how much did the household spend on Spices and condiments ?  
##           0           3           4           5           6           7           8           9          10 
##          14           1           2           8           3           3           4           4          49 
##          11          12          13          14          15          16          17          18          20 
##           4          13           1           4          27           2           3           4         144 
##          21          22          23          24          25          26          27          28          29 
##           3           2           4           4          29           2           3           4           1 
##          30          31          32          34          35          36          37          38          40 
##         131           1           5           2          26           7           2           7          36 
##          41          42          43          44          45          46          47          48          49 
##           6           4           2           1           9           2           1           1           1 
##          50          51          52          53          54          55          56          57          58 
##         591           2           2           3           4           6           2           1           4 
##          60          63          64          65          66          67          68          70          71 
##          56           1           1           4           1           2           1          40           1 
##          73          75          80          83          86          90          92          93          95 
##           2           8          26           1           1           5           1           2           1 
##          96         100         102         105         108         110         120         123         125 
##           1         502           1           4           2           1          13           1           1 
##         130         140         150         156         160         170         180         200         210 
##           2          11         111           1           2           1           3         137           1 
##         230         233         245         250         270         280         300         320         350 
##           1           1           1          13           1           1          65           1           7 
##         400         490 500 or more        <NA> 
##           4           1          19          31

percentile_99.5 <- floor(quantile(na.exclude(mydata$s9q14)[na.exclude(mydata$s9q14)!=999999], probs = c(0.995)))
mydata <- top_recode (variable="s9q14", break_point=percentile_99.5, missing=999999)
## [1] "Frequency table before encoding"
## s9q14. In the last 7 days how much did the household spend on Prepared foods ?  Sa naka
##    0    5   10   14   15   20   24   25   30   34   35   40   42   45   50   60   62   68   70   75   80   85 
##    9    2   15    1   12   48    2   18   58    1   16   48    1    9  101   56    1    1   23   11   26    2 
##   90   98  100  102  105  110  120  125  126  130  135  140  147  150  160  170  175  180  200  210  230  240 
##   24    1   91    1   15    2   13    1    1    2    1   25    1   48    3    1    1   14   34   10    1    2 
##  245  250  280  300  315  320  350  375  400  420  450  455  480  490  500  525  560  600  630  700  840  900 
##    3    7   11   28    1    1   10    1    5    4    1    1    1    3    6    1    3    1    2    4    1    1 
## 1000 <NA> 
##    2 1445

## [1] "Frequency table after encoding"
## s9q14. In the last 7 days how much did the household spend on Prepared foods ?  Sa naka
##           0           5          10          14          15          20          24          25          30 
##           9           2          15           1          12          48           2          18          58 
##          34          35          40          42          45          50          60          62          68 
##           1          16          48           1           9         101          56           1           1 
##          70          75          80          85          90          98         100         102         105 
##          23          11          26           2          24           1          91           1          15 
##         110         120         125         126         130         135         140         147         150 
##           2          13           1           1           2           1          25           1          48 
##         160         170         175         180         200         210         230         240         245 
##           3           1           1          14          34          10           1           2           3 
##         250         280         300         315         320         350         375         400         420 
##           7          11          28           1           1          10           1           5           4 
##         450         455         480         490         500         525         560         600         630 
##           1           1           1           3           6           1           3           1           2 
## 700 or more        <NA> 
##           8        1445

percentile_99.5 <- floor(quantile(na.exclude(mydata$s9q15other)[na.exclude(mydata$s9q15other)!=999999], probs = c(0.995)))
mydata <- top_recode (variable="s9q15other", break_point=percentile_99.5, missing=999999)
## [1] "Frequency table before encoding"
## s9q15other. In the last 7 days how much did the household spend on other food items?  Sa nak
##     0     5     7     8    10    15    20    21    24    25    30    34    35    36    40    45    50    58 
##  1567     2     1     3     1     1     8     1     1     1     6     1     1     1     5     3    16     1 
##    60    70    75    80   100   105   120   126   130   136   140   144   150   168   200   210   245   250 
##     8     4     2     1    20     3     1     1     1     1     4     1     5     1     8     1     1     1 
##   256   260   280   300   350   476   495   500   525   550   600   630   660   700   850  1000  1050  1148 
##     1     1     2     4     1     1     1     3     1     1     1     1     1     2     1     2     1     1 
##  1200  1400  1520  1900  2000  3500  5000  6000 15000  <NA> 
##     1     1     1     1     3     2     1     1     1   574

## [1] "Frequency table after encoding"
## s9q15other. In the last 7 days how much did the household spend on other food items?  Sa nak
##            0            5            7            8           10           15           20           21 
##         1567            2            1            3            1            1            8            1 
##           24           25           30           34           35           36           40           45 
##            1            1            6            1            1            1            5            3 
##           50           58           60           70           75           80          100          105 
##           16            1            8            4            2            1           20            3 
##          120          126          130          136          140          144          150          168 
##            1            1            1            1            4            1            5            1 
##          200          210          245          250          256          260          280          300 
##            8            1            1            1            1            1            2            4 
##          350          476          495          500          525          550          600          630 
##            1            1            1            3            1            1            1            1 
##          660          700          850         1000         1050         1148         1200         1400 
##            1            2            1            2            1            1            1            1 
##         1520 1670 or more         <NA> 
##            1            9          574

percentile_99.5 <- floor(quantile(na.exclude(mydata$s9q32)[na.exclude(mydata$s9q32)!=999999], probs = c(0.995)))
mydata <- top_recode (variable="s9q32", break_point=percentile_99.5, missing=999999)
## [1] "Frequency table before encoding"
## s9q32. In the last 30 days how much did the household spend on Airtime, internet, other
##    0    5   10   11   12   13   15   17   18   20   21   22   23   24   25   26   27   28   30   32   33   34 
##   79    2   25    1   20   14   41   10    5   55    1   17   21    8    4   17    1    1  101    4    1   15 
##   35   36   39   40   42   44   45   46   47   48   50   51   52   54   55   60   63   64   65   66   68   69 
##    5    8    9   62    1    6   13    8    1   15  109    2   20    4    2  110    1    3    1    3    9    4 
##   70   72   75   80   83   84   88   90   92   96   99  100  102  104  105  110  112  120  126  128  132  136 
##    8    9    4   67    1    1   17   10    9    5    2  194    3    8    1    1    1   60    1    1    2    4 
##  140  144  146  148  150  156  160  161  165  168  170  175  176  180  184  192  195  200  210  215  219  220 
##    2    6    1    1   79    3   16    1    1    1    2    1    2   11    4    3    2  108    2    1    1    1 
##  224  225  230  240  243  250  254  255  260  264  270  272  276  280  284  288  296  300  304  306  308  320 
##    1    2    2   19    1   10    1    1    5    4    1    1    2    4    1    1    1   91    2    1    1    9 
##  324  325  336  344  350  352  356  360  364  392  400  408  416  420  430  440  450  492  500  510  517  520 
##    2    1    1    1    6    1    1    3    2    1   19    3    1    2    1    1    2    2   28    1    1    1 
##  528  550  600  660  680  720  750  800  836  900  930  960 1000 1050 1099 1400 1500 1650 1800 2000 2100 2640 
##    1    1   16    2    1    1    2    4    1    2    1    1    7    1    1    1    2    1    1    2    1    1 
## 3600 <NA> 
##    1  505

## [1] "Frequency table after encoding"
## s9q32. In the last 30 days how much did the household spend on Airtime, internet, other
##            0            5           10           11           12           13           15           17 
##           79            2           25            1           20           14           41           10 
##           18           20           21           22           23           24           25           26 
##            5           55            1           17           21            8            4           17 
##           27           28           30           32           33           34           35           36 
##            1            1          101            4            1           15            5            8 
##           39           40           42           44           45           46           47           48 
##            9           62            1            6           13            8            1           15 
##           50           51           52           54           55           60           63           64 
##          109            2           20            4            2          110            1            3 
##           65           66           68           69           70           72           75           80 
##            1            3            9            4            8            9            4           67 
##           83           84           88           90           92           96           99          100 
##            1            1           17           10            9            5            2          194 
##          102          104          105          110          112          120          126          128 
##            3            8            1            1            1           60            1            1 
##          132          136          140          144          146          148          150          156 
##            2            4            2            6            1            1           79            3 
##          160          161          165          168          170          175          176          180 
##           16            1            1            1            2            1            2           11 
##          184          192          195          200          210          215          219          220 
##            4            3            2          108            2            1            1            1 
##          224          225          230          240          243          250          254          255 
##            1            2            2           19            1           10            1            1 
##          260          264          270          272          276          280          284          288 
##            5            4            1            1            2            4            1            1 
##          296          300          304          306          308          320          324          325 
##            1           91            2            1            1            9            2            1 
##          336          344          350          352          356          360          364          392 
##            1            1            6            1            1            3            2            1 
##          400          408          416          420          430          440          450          492 
##           19            3            1            2            1            1            2            2 
##          500          510          517          520          528          550          600          660 
##           28            1            1            1            1            1           16            2 
##          680          720          750          800          836          900          930          960 
##            1            1            2            4            1            2            1            1 
##         1000         1050         1099         1400 1404 or more         <NA> 
##            7            1            1            1            9          505

percentile_99.5 <- floor(quantile(na.exclude(mydata$s9q33)[na.exclude(mydata$s9q33)!=999999], probs = c(0.995)))
mydata <- top_recode (variable="s9q33", break_point=percentile_99.5, missing=999999)
## [1] "Frequency table before encoding"
## s9q33. In the last 30 days how much did the household spend on Travel, transport, hotel
##     0     5     9    10    14    16    20    24    25    26    28    30    32    34    36    40    42    44 
##    26     1     1     4     1     4    12     2     1     1     1    14     7     4     3    37     1     2 
##    48    50    51    52    53    56    60    64    68    70    72    75    76    80    90    96   100   104 
##     1    38     1     1     1     3    21     3     2     9     1     3     3    30     8     2    93     2 
##   112   120   136   140   144   150   154   160   170   180   200   210   220   224   240   250   260   270 
##     1    18     2     7     3    17     2    21     2     8    74     5     1     2    11     8     2     2 
##   280   281   288   300   304   308   310   312   320   325   328   350   360   370   384   390   400   450 
##    13     1     2    59     1     1     1     2     9     1     1     1     5     1     1     1    30     2 
##   480   500   520   560   600   640   648   660   680   700   720   750   780   784   800   832   840   864 
##    17    58     1     7    24     1     1     1     1     6     5     3     1     1    11     1     3     1 
##   900   920   930   960   990  1000  1030  1032  1050  1056  1080  1140  1160  1200  1240  1250  1260  1280 
##    12     1     1     3     1    16     1     1     1     1     1     2     4    16     1     1     1     1 
##  1300  1320  1400  1470  1500  1580  1600  1620  1640  1680  1700  1800  1860  1920  2000  2080  2090  2100 
##     1     2     1     1    12     1     1     1     1     3     1     2     1     1    13     1     1     2 
##  2112  2120  2200  2250  2300  2400  2496  2500  2600  2700  2880  2980  3000  3420  4000  4050  4200  4500 
##     1     1     2     1     1     3     1     2     1     1     3     1     9     1     5     1     2     2 
##  4576  5200  5600  6000  7020  7840  8000 12800 61500  <NA> 
##     1     1     1     1     1     1     1     1     1  1333

## [1] "Frequency table after encoding"
## s9q33. In the last 30 days how much did the household spend on Travel, transport, hotel
##            0            5            9           10           14           16           20           24 
##           26            1            1            4            1            4           12            2 
##           25           26           28           30           32           34           36           40 
##            1            1            1           14            7            4            3           37 
##           42           44           48           50           51           52           53           56 
##            1            2            1           38            1            1            1            3 
##           60           64           68           70           72           75           76           80 
##           21            3            2            9            1            3            3           30 
##           90           96          100          104          112          120          136          140 
##            8            2           93            2            1           18            2            7 
##          144          150          154          160          170          180          200          210 
##            3           17            2           21            2            8           74            5 
##          220          224          240          250          260          270          280          281 
##            1            2           11            8            2            2           13            1 
##          288          300          304          308          310          312          320          325 
##            2           59            1            1            1            2            9            1 
##          328          350          360          370          384          390          400          450 
##            1            1            5            1            1            1           30            2 
##          480          500          520          560          600          640          648          660 
##           17           58            1            7           24            1            1            1 
##          680          700          720          750          780          784          800          832 
##            1            6            5            3            1            1           11            1 
##          840          864          900          920          930          960          990         1000 
##            3            1           12            1            1            3            1           16 
##         1030         1032         1050         1056         1080         1140         1160         1200 
##            1            1            1            1            1            2            4           16 
##         1240         1250         1260         1280         1300         1320         1400         1470 
##            1            1            1            1            1            2            1            1 
##         1500         1580         1600         1620         1640         1680         1700         1800 
##           12            1            1            1            1            3            1            2 
##         1860         1920         2000         2080         2090         2100         2112         2120 
##            1            1           13            1            1            2            1            1 
##         2200         2250         2300         2400         2496         2500         2600         2700 
##            2            1            1            3            1            2            1            1 
##         2880         2980         3000         3420         4000         4050         4200         4500 
##            3            1            9            1            5            1            2            2 
##         4576         5200         5600         6000 6193 or more         <NA> 
##            1            1            1            1            5         1333

percentile_99.5 <- floor(quantile(na.exclude(mydata$s9q34)[na.exclude(mydata$s9q34)!=999999], probs = c(0.995)))
mydata <- top_recode (variable="s9q34", break_point=percentile_99.5, missing=999999)
## [1] "Frequency table before encoding"
## s9q34. In the last 30 days how much did the household spend on Lottery tickets/gambling
##    0    3    5    6   10   15   20   25   27   30   35   40   50   60   80   90  100  105  120  150  160  180 
##    7    1    1    2   13    6   34    1    1   18    2   18   30    8    9    4   30    2    6   15    5    1 
##  200  220  240  280  300  320  360  365  400  420  450  480  500  600  900 1000 1400 1500 1800 2000 2100 2400 
##   20    1    5    1   22    1    1    1    5    1    3    1    5    5    4    2    1    1    4    1    1    1 
## 2500 3000 3650 4000 <NA> 
##    1    1    1    1 1991

## [1] "Frequency table after encoding"
## s9q34. In the last 30 days how much did the household spend on Lottery tickets/gambling
##            0            3            5            6           10           15           20           25 
##            7            1            1            2           13            6           34            1 
##           27           30           35           40           50           60           80           90 
##            1           18            2           18           30            8            9            4 
##          100          105          120          150          160          180          200          220 
##           30            2            6           15            5            1           20            1 
##          240          280          300          320          360          365          400          420 
##            5            1           22            1            1            1            5            1 
##          450          480          500          600          900         1000         1400         1500 
##            3            1            5            5            4            2            1            1 
##         1800         2000         2100         2400         2500         3000 3312 or more         <NA> 
##            4            1            1            1            1            1            2         1991

percentile_99.5 <- floor(quantile(na.exclude(mydata$s9q35)[na.exclude(mydata$s9q35)!=999999], probs = c(0.995)))
mydata <- top_recode (variable="s9q35", break_point=percentile_99.5, missing=999999)
## [1] "Frequency table before encoding"
## s9q35. In the last 30 days how much did the household spend on Clothing and shoes ?  Sa
##     0    10    20    25    30    35    45    50    60    65    70    80    85    90    96   100   105   110 
##     7     1     2     2     2     1     1    13     1     1     4     5     1     6     1    38     1     3 
##   120   125   130   132   140   150   160   165   180   190   195   200   205   210   220   225   226   230 
##     5     1     5     1     1    28     4     1     4     3     1    50     1     2     4     1     1     1 
##   240   250   260   270   280   285   290   295   300   310   320   325   330   332   335   350   355   360 
##     4    26     2     3     9     1     2     2    51     2     1     1     3     1     2    20     1     3 
##   370   380   400   405   410   420   425   430   440   450   455   460   465   470   475   480   495   500 
##     2     5    19     1     1     2     1     2     1    10     1     1     1     3     1     3     1    82 
##   505   510   515   520   530   550   560   580   600   620   640   650   670   700   709   745   750   765 
##     1     1     1     1     1     8     2     2    18     1     3     6     1    17     1     1     6     1 
##   779   800   850   900   950   960  1000  1060  1070  1080  1100  1120  1140  1150  1200  1230  1250  1300 
##     1    11     3     5     1     1    48     1     1     1     4     1     1     1     3     1     2     3 
##  1350  1400  1440  1450  1500  1600  1880  1900  2000  2080  2100  2300  2500  2600  2790  2800  3000  3600 
##     1     1     1     1    24     5     1     1    18     1     1     1     2     3     1     2    11     1 
##  4500  5000 10000 16000  <NA> 
##     1     2     1     1  1579

## [1] "Frequency table after encoding"
## s9q35. In the last 30 days how much did the household spend on Clothing and shoes ?  Sa
##            0           10           20           25           30           35           45           50 
##            7            1            2            2            2            1            1           13 
##           60           65           70           80           85           90           96          100 
##            1            1            4            5            1            6            1           38 
##          105          110          120          125          130          132          140          150 
##            1            3            5            1            5            1            1           28 
##          160          165          180          190          195          200          205          210 
##            4            1            4            3            1           50            1            2 
##          220          225          226          230          240          250          260          270 
##            4            1            1            1            4           26            2            3 
##          280          285          290          295          300          310          320          325 
##            9            1            2            2           51            2            1            1 
##          330          332          335          350          355          360          370          380 
##            3            1            2           20            1            3            2            5 
##          400          405          410          420          425          430          440          450 
##           19            1            1            2            1            2            1           10 
##          455          460          465          470          475          480          495          500 
##            1            1            1            3            1            3            1           82 
##          505          510          515          520          530          550          560          580 
##            1            1            1            1            1            8            2            2 
##          600          620          640          650          670          700          709          745 
##           18            1            3            6            1           17            1            1 
##          750          765          779          800          850          900          950          960 
##            6            1            1           11            3            5            1            1 
##         1000         1060         1070         1080         1100         1120         1140         1150 
##           48            1            1            1            4            1            1            1 
##         1200         1230         1250         1300         1350         1400         1440         1450 
##            3            1            2            3            1            1            1            1 
##         1500         1600         1880         1900         2000         2080         2100         2300 
##           24            5            1            1           18            1            1            1 
##         2500         2600         2790         2800         3000         3600         4500 4709 or more 
##            2            3            1            2           11            1            1            4 
##         <NA> 
##         1579

percentile_99.5 <- floor(quantile(na.exclude(mydata$s9q36)[na.exclude(mydata$s9q36)!=999999], probs = c(0.995)))
mydata <- top_recode (variable="s9q36", break_point=percentile_99.5, missing=999999)
## [1] "Frequency table before encoding"
## s9q36. In the last 30 days how much did the household spend on Recreation/entertainment
##    0   20   50   81  100  120  150  180  200  235  250  300  350  380  400  470  500  700  800  900 1000 1200 
##    6    1    2    1    8    2    1    1    9    1    1    6    1    1    2    1   16    1    1    1    4    1 
## 2000 3000 4000 5000 <NA> 
##    4    1    1    2 2220

## [1] "Frequency table after encoding"
## s9q36. In the last 30 days how much did the household spend on Recreation/entertainment
##            0           20           50           81          100          120          150          180 
##            6            1            2            1            8            2            1            1 
##          200          235          250          300          350          380          400          470 
##            9            1            1            6            1            1            2            1 
##          500          700          800          900         1000         1200         2000         3000 
##           16            1            1            1            4            1            4            1 
##         4000 5000 or more         <NA> 
##            1            2         2220

percentile_99.5 <- floor(quantile(na.exclude(mydata$s9q37)[na.exclude(mydata$s9q37)!=999999], probs = c(0.995)))
mydata <- top_recode (variable="s9q37", break_point=percentile_99.5, missing=999999)
## [1] "Frequency table before encoding"
## s9q37. In the last 30 days how much did the household spend on Personal items  ?  Sa na
##    0    6    7    8   10   12   14   15   16   18   20   21   22   24   25   27   28   30   32   33   34   35 
##   19    1    3    3    3    1   11    8    2    5   19    8    1   22   11    1   30   26   17    5    1   15 
##   36   38   40   42   44   45   46   48   49   50   51   52   53   54   55   56   57   58   60   63   64   65 
##    5    6   30    7    4    6    3   16    3   92    1    2    3    2    5   35    1    2   35    2   16    6 
##   66   67   68   70   71   72   73   75   76   78   79   80   82   83   84   85   86   87   88   89   90   91 
##    5    2    5   18    3   13    2    8    4    5    2   39    2    2   12    1    4    1    2    4    9    1 
##   92   93   94   95   96   97   98   99  100  101  102  104  105  106  108  109  110  112  113  114  115  116 
##    7    1    3    3   11    1    2   10  248    1    1    2   13    4    1    6   12    3    1    3    4    3 
##  117  118  119  120  121  124  125  126  127  128  129  130  131  132  133  134  135  136  137  138  139  140 
##    1   11    9   26    1    5    9    3    2    6    1    6    1    6    3    1    2    1    3    3    1    4 
##  141  142  143  144  145  146  147  149  150  152  153  154  155  156  157  158  159  160  162  163  164  165 
##    1    1    2    3    4    1    2    2  129    1    1    1    2    5    1    2    1   13    3    1    5    4 
##  166  168  169  170  172  173  174  175  176  177  178  179  180  181  183  184  185  186  187  188  190  191 
##    4    4    1    3    1    1    3    1    1    1    1    1   10    1    2    1    2    1    1    1    6    1 
##  192  193  194  196  197  200  202  204  205  206  208  209  210  212  216  217  219  220  222  225  227  228 
##    1    2    1    3    1  204    1    2    1    2    2    2    4    1    1    1    3    6    1    2    1    2 
##  229  230  233  234  235  236  238  240  243  244  246  250  256  259  260  264  268  270  273  277  278  280 
##    1    6    1    2    1    2    5   10    1    3    1   59    2    2    4    1    3    2    1    1    2    4 
##  283  284  285  286  287  290  295  296  299  300  305  308  309  310  315  320  322  324  325  326  330  332 
##    1    1    2    1    2    1    3    2    1  119    1    2    1    3    1    4    2    2    2    1    1    1 
##  335  338  339  340  345  347  348  349  350  355  356  360  367  370  371  375  380  390  392  400  409  416 
##    1    4    2    3    1    1    1    1   16    1    1    2    1    3    1    1    1    2    1   23    1    1 
##  417  424  429  430  436  448  450  460  480  482  497  500  504  511  520  529  530  538  545  550  560  573 
##    1    1    2    1    1    1    5    1    2    1    1   91    1    1    2    1    1    1    1    2    1    1 
##  578  595  600  610  628  634  650  660  700  744  750  800  867  870  944  980  985 1000 1200 1250 1500 2000 
##    1    1   12    1    1    1    1    1    1    1    1    2    1    1    1    1    1   17    1    2    3    1 
## 3000 <NA> 
##    2  224

## [1] "Frequency table after encoding"
## s9q37. In the last 30 days how much did the household spend on Personal items  ?  Sa na
##            0            6            7            8           10           12           14           15 
##           19            1            3            3            3            1           11            8 
##           16           18           20           21           22           24           25           27 
##            2            5           19            8            1           22           11            1 
##           28           30           32           33           34           35           36           38 
##           30           26           17            5            1           15            5            6 
##           40           42           44           45           46           48           49           50 
##           30            7            4            6            3           16            3           92 
##           51           52           53           54           55           56           57           58 
##            1            2            3            2            5           35            1            2 
##           60           63           64           65           66           67           68           70 
##           35            2           16            6            5            2            5           18 
##           71           72           73           75           76           78           79           80 
##            3           13            2            8            4            5            2           39 
##           82           83           84           85           86           87           88           89 
##            2            2           12            1            4            1            2            4 
##           90           91           92           93           94           95           96           97 
##            9            1            7            1            3            3           11            1 
##           98           99          100          101          102          104          105          106 
##            2           10          248            1            1            2           13            4 
##          108          109          110          112          113          114          115          116 
##            1            6           12            3            1            3            4            3 
##          117          118          119          120          121          124          125          126 
##            1           11            9           26            1            5            9            3 
##          127          128          129          130          131          132          133          134 
##            2            6            1            6            1            6            3            1 
##          135          136          137          138          139          140          141          142 
##            2            1            3            3            1            4            1            1 
##          143          144          145          146          147          149          150          152 
##            2            3            4            1            2            2          129            1 
##          153          154          155          156          157          158          159          160 
##            1            1            2            5            1            2            1           13 
##          162          163          164          165          166          168          169          170 
##            3            1            5            4            4            4            1            3 
##          172          173          174          175          176          177          178          179 
##            1            1            3            1            1            1            1            1 
##          180          181          183          184          185          186          187          188 
##           10            1            2            1            2            1            1            1 
##          190          191          192          193          194          196          197          200 
##            6            1            1            2            1            3            1          204 
##          202          204          205          206          208          209          210          212 
##            1            2            1            2            2            2            4            1 
##          216          217          219          220          222          225          227          228 
##            1            1            3            6            1            2            1            2 
##          229          230          233          234          235          236          238          240 
##            1            6            1            2            1            2            5           10 
##          243          244          246          250          256          259          260          264 
##            1            3            1           59            2            2            4            1 
##          268          270          273          277          278          280          283          284 
##            3            2            1            1            2            4            1            1 
##          285          286          287          290          295          296          299          300 
##            2            1            2            1            3            2            1          119 
##          305          308          309          310          315          320          322          324 
##            1            2            1            3            1            4            2            2 
##          325          326          330          332          335          338          339          340 
##            2            1            1            1            1            4            2            3 
##          345          347          348          349          350          355          356          360 
##            1            1            1            1           16            1            1            2 
##          367          370          371          375          380          390          392          400 
##            1            3            1            1            1            2            1           23 
##          409          416          417          424          429          430          436          448 
##            1            1            1            1            2            1            1            1 
##          450          460          480          482          497          500          504          511 
##            5            1            2            1            1           91            1            1 
##          520          529          530          538          545          550          560          573 
##            2            1            1            1            1            2            1            1 
##          578          595          600          610          628          634          650          660 
##            1            1           12            1            1            1            1            1 
##          700          744          750          800          867          870          944          980 
##            1            1            1            2            1            1            1            1 
##          985 1000 or more         <NA> 
##            1           26          224

percentile_99.5 <- floor(quantile(na.exclude(mydata$s9q38)[na.exclude(mydata$s9q38)!=999999], probs = c(0.995)))
mydata <- top_recode (variable="s9q38", break_point=percentile_99.5, missing=999999)
## [1] "Frequency table before encoding"
## s9q38. In the last 30 days how much did the household spend on Household items?  Sa nak
##    0    4   15   17   18   20   24   25   29   30   32   35   38   40   42   45   46   48   50   52   54   55 
##   10    1    1    1    3    4    5    2    1    2    1    2    1    8    3    2    2    2   42    3    4    4 
##   56   57   58   59   60   61   62   63   65   66   68   69   70   71   72   74   75   76   77   78   80   81 
##    4    1    1    1   14    1    3    2    2    3    2    1    9    1    9    2    1    1    1    4   16    1 
##   82   83   84   85   86   87   88   89   90   91   92   93   94   96   97   99  100  101  102  104  105  106 
##    1    1    3    2    1    1    5    1    4    1    2    2    1    7    1    1  208    1    1    2    5    2 
##  108  109  110  112  114  116  117  118  119  120  122  123  124  125  126  128  129  130  131  132  134  135 
##    5    1    4    3    2    4    2    2    1   22    2    1    2    1    3    5    2    7    2    2    2    1 
##  136  137  138  139  140  144  145  146  148  149  150  152  153  154  155  156  158  159  160  162  164  165 
##    5    1    3    1    6   11    3    2    3    1  150    6    1    1    2    5    2    3   13    2    2    2 
##  166  167  168  169  170  171  172  173  174  176  178  180  181  184  185  187  189  190  192  193  196  198 
##    2    1    6    1    4    2    2    2    1    5    2   24    1    2    1    1    1    1    5    1    1    5 
##  200  202  204  206  208  210  211  213  214  215  216  217  218  220  222  224  226  228  230  232  234  235 
##  306    1    1    2    2    4    2    1    1    1   10    1    2    8    2    3    2    4    5    4    2    2 
##  236  240  241  244  245  246  247  248  250  252  253  255  256  258  260  261  264  265  266  268  270  272 
##    1   15    1    2    1    3    1    3   72    2    1    3    3    1    8    2    3    3    1    3    5    4 
##  275  276  278  280  284  288  289  292  293  295  296  300  304  306  308  311  312  314  316  318  320  322 
##    1    4    2   17    2    7    1    3    1    1    3  236    2    2    1    1    2    1    2    1    9    1 
##  324  325  326  328  330  332  334  336  338  340  342  344  345  348  350  354  356  357  360  368  369  370 
##    3    1    2    3    5    1    2    1    3    6    1    1    2    1   27    1    2    2   11    2    1    2 
##  372  376  379  380  384  386  390  392  394  395  396  398  400  402  404  405  408  410  416  420  424  428 
##    2    2    1    7    2    1    2    2    1    1    3    1   67    1    1    2    6    2    1    4    1    2 
##  430  431  432  436  440  444  448  450  452  456  459  460  466  468  470  472  476  480  486  488  492  496 
##    1    2    4    2    4    1    2    8    1    2    1    1    2    1    1    4    2    8    1    2    1    1 
##  498  500  505  508  510  511  520  524  526  536  544  550  560  565  576  578  580  584  588  592  594  596 
##    1  186    1    1    1    1    9    2    1    1    1    2    5    1    2    1    1    1    1    1    1    1 
##  600  616  620  624  630  632  634  636  640  646  650  652  680  696  698  700  708  720  730  750  752  756 
##   24    1    1    1    3    1    1    1    1    1    4    1    5    1    1   10    1    2    1    1    1    1 
##  763  765  792  800  810  860  876  888  900  960  970  975 1000 1020 1100 1104 1200 1248 1260 1280 1300 1380 
##    1    1    1   20    1    1    1    1    2    1    1    1   36    1    1    1    3    1    1    1    1    1 
## 1400 1410 1480 1500 1640 1720 1800 2000 3000 <NA> 
##    1    1    1   10    1    1    1    5    2   51

## [1] "Frequency table after encoding"
## s9q38. In the last 30 days how much did the household spend on Household items?  Sa nak
##            0            4           15           17           18           20           24           25 
##           10            1            1            1            3            4            5            2 
##           29           30           32           35           38           40           42           45 
##            1            2            1            2            1            8            3            2 
##           46           48           50           52           54           55           56           57 
##            2            2           42            3            4            4            4            1 
##           58           59           60           61           62           63           65           66 
##            1            1           14            1            3            2            2            3 
##           68           69           70           71           72           74           75           76 
##            2            1            9            1            9            2            1            1 
##           77           78           80           81           82           83           84           85 
##            1            4           16            1            1            1            3            2 
##           86           87           88           89           90           91           92           93 
##            1            1            5            1            4            1            2            2 
##           94           96           97           99          100          101          102          104 
##            1            7            1            1          208            1            1            2 
##          105          106          108          109          110          112          114          116 
##            5            2            5            1            4            3            2            4 
##          117          118          119          120          122          123          124          125 
##            2            2            1           22            2            1            2            1 
##          126          128          129          130          131          132          134          135 
##            3            5            2            7            2            2            2            1 
##          136          137          138          139          140          144          145          146 
##            5            1            3            1            6           11            3            2 
##          148          149          150          152          153          154          155          156 
##            3            1          150            6            1            1            2            5 
##          158          159          160          162          164          165          166          167 
##            2            3           13            2            2            2            2            1 
##          168          169          170          171          172          173          174          176 
##            6            1            4            2            2            2            1            5 
##          178          180          181          184          185          187          189          190 
##            2           24            1            2            1            1            1            1 
##          192          193          196          198          200          202          204          206 
##            5            1            1            5          306            1            1            2 
##          208          210          211          213          214          215          216          217 
##            2            4            2            1            1            1           10            1 
##          218          220          222          224          226          228          230          232 
##            2            8            2            3            2            4            5            4 
##          234          235          236          240          241          244          245          246 
##            2            2            1           15            1            2            1            3 
##          247          248          250          252          253          255          256          258 
##            1            3           72            2            1            3            3            1 
##          260          261          264          265          266          268          270          272 
##            8            2            3            3            1            3            5            4 
##          275          276          278          280          284          288          289          292 
##            1            4            2           17            2            7            1            3 
##          293          295          296          300          304          306          308          311 
##            1            1            3          236            2            2            1            1 
##          312          314          316          318          320          322          324          325 
##            2            1            2            1            9            1            3            1 
##          326          328          330          332          334          336          338          340 
##            2            3            5            1            2            1            3            6 
##          342          344          345          348          350          354          356          357 
##            1            1            2            1           27            1            2            2 
##          360          368          369          370          372          376          379          380 
##           11            2            1            2            2            2            1            7 
##          384          386          390          392          394          395          396          398 
##            2            1            2            2            1            1            3            1 
##          400          402          404          405          408          410          416          420 
##           67            1            1            2            6            2            1            4 
##          424          428          430          431          432          436          440          444 
##            1            2            1            2            4            2            4            1 
##          448          450          452          456          459          460          466          468 
##            2            8            1            2            1            1            2            1 
##          470          472          476          480          486          488          492          496 
##            1            4            2            8            1            2            1            1 
##          498          500          505          508          510          511          520          524 
##            1          186            1            1            1            1            9            2 
##          526          536          544          550          560          565          576          578 
##            1            1            1            2            5            1            2            1 
##          580          584          588          592          594          596          600          616 
##            1            1            1            1            1            1           24            1 
##          620          624          630          632          634          636          640          646 
##            1            1            3            1            1            1            1            1 
##          650          652          680          696          698          700          708          720 
##            4            1            5            1            1           10            1            2 
##          730          750          752          756          763          765          792          800 
##            1            1            1            1            1            1            1           20 
##          810          860          876          888          900          960          970          975 
##            1            1            1            1            2            1            1            1 
##         1000         1020         1100         1104         1200         1248         1260         1280 
##           36            1            1            1            3            1            1            1 
##         1300         1380         1400         1410         1480 1500 or more         <NA> 
##            1            1            1            1            1           20           51

percentile_99.5 <- floor(quantile(na.exclude(mydata$s9q39)[na.exclude(mydata$s9q39)!=999999], probs = c(0.995)))
mydata <- top_recode (variable="s9q39", break_point=percentile_99.5, missing=999999)
## [1] "Frequency table before encoding"
## s9q39. In the last 30 days how much did the household spend on Firewood, kerosene, and 
##    0   10   12   15   18   20   24   30   35   40   50   53   60   70   72   80   84   85   90  100  112  120 
##   11    1    1    1    1    3    1    6    1    3    7    1    2    4    1    1    1    2    2   15    1   10 
##  125  126  130  134  138  140  150  160  167  168  170  171  173  175  180  186  190  200  210  220  225  226 
##    1    1    3    1    1   10   39   14    1    1   11    1    1    2   20    1    3   55    2    5    3    1 
##  230  233  240  245  250  258  260  262  270  275  280  300  310  320  325  326  330  336  340  345  350  353 
##    5    2   17    1   30    1    8    1    5    3    6   63    2   10    1    1    2    2    5    1    6    1 
##  360  375  380  390  395  400  410  420  425  430  435  440  450  460  470  475  480  485  490  500  506  508 
##   14    1    3    1    1   30    2   11    2    9    2    8   28    5    6    3   22    1    4   51    1    1 
##  510  515  520  530  540  548  550  560  562  565  575  580  593  600  630  640  650  660  665  672  680  690 
##    1    1   10    6   11    1    7    3    1    1    2    6    1   43    5    2    4    2    1    1    4    1 
##  700  720  768  800  840  858  900 1000 1008 1150 1200 1377 1400 1500 1680 1800 2880 <NA> 
##    7    6    1    8    2    1   16    3    1    1    3    1    1    3    1    1    1 1493

## [1] "Frequency table after encoding"
## s9q39. In the last 30 days how much did the household spend on Firewood, kerosene, and 
##            0           10           12           15           18           20           24           30 
##           11            1            1            1            1            3            1            6 
##           35           40           50           53           60           70           72           80 
##            1            3            7            1            2            4            1            1 
##           84           85           90          100          112          120          125          126 
##            1            2            2           15            1           10            1            1 
##          130          134          138          140          150          160          167          168 
##            3            1            1           10           39           14            1            1 
##          170          171          173          175          180          186          190          200 
##           11            1            1            2           20            1            3           55 
##          210          220          225          226          230          233          240          245 
##            2            5            3            1            5            2           17            1 
##          250          258          260          262          270          275          280          300 
##           30            1            8            1            5            3            6           63 
##          310          320          325          326          330          336          340          345 
##            2           10            1            1            2            2            5            1 
##          350          353          360          375          380          390          395          400 
##            6            1           14            1            3            1            1           30 
##          410          420          425          430          435          440          450          460 
##            2           11            2            9            2            8           28            5 
##          470          475          480          485          490          500          506          508 
##            6            3           22            1            4           51            1            1 
##          510          515          520          530          540          548          550          560 
##            1            1           10            6           11            1            7            3 
##          562          565          575          580          593          600          630          640 
##            1            1            2            6            1           43            5            2 
##          650          660          665          672          680          690          700          720 
##            4            2            1            1            4            1            7            6 
##          768          800          840          858          900         1000         1008         1150 
##            1            8            2            1           16            3            1            1 
##         1200         1377         1400 1500 or more         <NA> 
##            3            1            1            6         1493

percentile_99.5 <- floor(quantile(na.exclude(mydata$s9q40)[na.exclude(mydata$s9q40)!=999999], probs = c(0.995)))
mydata <- top_recode (variable="s9q40", break_point=percentile_99.5, missing=999999)
## [1] "Frequency table before encoding"
## s9q40. In the last 30 days how much did the household spend on Electricity ?  Sa nakali
##    0    1   10   12   18   20   21   22   25   27   29   30   32   33   34   35   36   37   38   39   40   41 
##   20    1    3    1    1    5    1    1    2    1    4    8    1    1    1    4    1    1    3    1    5    2 
##   42   43   45   47   48   49   50   51   52   53   54   55   56   57   60   61   62   63   64   65   66   67 
##    1    3    4    3    6    1   38    1    4    3    4    4    2    5    9    1    5    1    1    7    2    3 
##   68   69   70   71   72   73   74   75   76   77   78   79   80   82   83   85   88   90   91   92   93   94 
##    6    2   12    1    4    1    1    6    2    1    3    7    8    2    2    5    1    5    3    1    3    1 
##   95   96   97   98   99  100  103  104  105  106  107  108  109  110  111  117  119  120  122  125  126  127 
##    4    3    2    1    1   83    1    2    3    1    1    1    1    2    3    1    1   22    1    6    1    1 
##  128  130  131  132  134  135  136  138  139  140  141  142  143  145  146  147  148  149  150  151  153  154 
##    1   10    1    1    1    3    1    2    1   13    1    1    3    2    1    2    1    1   70    1    2    1 
##  155  157  158  159  160  161  163  164  165  167  168  170  173  180  181  182  185  189  190  191  192  194 
##    2    1    1    1    5    2    1    1    5    1    1    9    1   14    2    1    5    1    6    1    1    2 
##  195  196  197  200  202  203  205  206  209  210  211  212  214  216  217  218  220  221  222  223  225  227 
##    2    4    2  147    1    2    2    1    2    5    1    2    1    2    1    5    6    3    2    2    1    3 
##  228  230  231  232  233  235  236  237  238  240  242  245  246  247  248  250  251  254  255  256  260  261 
##    1    8    1    1    1    6    1    1    1   10    1    1    2    1    1   61    1    4    3    5   11    1 
##  262  265  266  267  268  270  275  277  278  280  282  284  286  287  289  290  295  297  300  305  306  308 
##    3    2    1    1    2    8    2    1    1   21    1    2    1    1    3    4    2    2  165    1    1    1 
##  310  312  314  315  316  319  320  322  325  326  328  330  332  333  335  336  338  340  341  342  345  346 
##    2    3    1    2    2    1   11    1    7    1    1    3    1    1    2    2    1    6    1    1    3    1 
##  349  350  351  353  354  355  356  357  358  360  362  364  365  366  368  370  372  373  375  380  382  387 
##    1   56    3    1    2    1    2    2    1    6    1    1    5    1    2    4    1    1    3    7    1    2 
##  389  390  392  393  395  396  397  398  400  403  405  407  408  409  412  413  415  416  420  421  423  425 
##    2    3    1    1    1    1    1    1   73    1    1    1    1    1    1    1    1    1    3    1    1    2 
##  426  429  430  432  435  439  440  443  444  445  447  449  450  451  453  455  456  460  462  463  470  475 
##    1    1    5    1    1    1    2    1    2    1    1    1   17    2    1    1    1    2    1    1    1    2 
##  478  479  480  485  487  488  490  493  494  498  500  501  510  515  517  518  520  522  525  529  530  533 
##    1    1    6    1    1    1    1    1    1    1   91    1    1    1    1    1    5    1    1    2    1    1 
##  535  536  540  542  545  546  550  555  558  560  567  568  569  570  575  580  588  590  592  600  601  610 
##    1    1    4    1    3    1    4    2    1    3    1    1    1    2    1    4    1    2    1   65    1    1 
##  613  620  625  644  647  650  652  660  675  676  680  683  685  689  691  700  709  720  721  727  730  740 
##    1    3    1    1    1    5    1    3    1    1    1    1    2    1    1   49    1    1    1    1    1    1 
##  750  777  780  786  800  812  830  832  840  850  854  855  860  875  877  900  926  938  946  950  957  960 
##    6    1    5    3   28    1    1    1    1    3    1    1    2    1    1   18    1    1    2    2    1    1 
##  966  970  973  990  996  998 1000 1020 1026 1037 1040 1069 1080 1082 1100 1150 1200 1260 1270 1300 1387 1395 
##    1    1    1    1    1    1   36    1    1    1    1    1    1    1   10    1   17    1    1    9    1    1 
## 1400 1500 1550 1600 1700 1800 1900 2000 2003 2300 2400 2500 2600 2700 3000 3600 4900 9000 <NA> 
##    2   12    1    2    2    1    3    4    1    1    1    3    1    1    2    1    1    1  351

## [1] "Frequency table after encoding"
## s9q40. In the last 30 days how much did the household spend on Electricity ?  Sa nakali
##            0            1           10           12           18           20           21           22 
##           20            1            3            1            1            5            1            1 
##           25           27           29           30           32           33           34           35 
##            2            1            4            8            1            1            1            4 
##           36           37           38           39           40           41           42           43 
##            1            1            3            1            5            2            1            3 
##           45           47           48           49           50           51           52           53 
##            4            3            6            1           38            1            4            3 
##           54           55           56           57           60           61           62           63 
##            4            4            2            5            9            1            5            1 
##           64           65           66           67           68           69           70           71 
##            1            7            2            3            6            2           12            1 
##           72           73           74           75           76           77           78           79 
##            4            1            1            6            2            1            3            7 
##           80           82           83           85           88           90           91           92 
##            8            2            2            5            1            5            3            1 
##           93           94           95           96           97           98           99          100 
##            3            1            4            3            2            1            1           83 
##          103          104          105          106          107          108          109          110 
##            1            2            3            1            1            1            1            2 
##          111          117          119          120          122          125          126          127 
##            3            1            1           22            1            6            1            1 
##          128          130          131          132          134          135          136          138 
##            1           10            1            1            1            3            1            2 
##          139          140          141          142          143          145          146          147 
##            1           13            1            1            3            2            1            2 
##          148          149          150          151          153          154          155          157 
##            1            1           70            1            2            1            2            1 
##          158          159          160          161          163          164          165          167 
##            1            1            5            2            1            1            5            1 
##          168          170          173          180          181          182          185          189 
##            1            9            1           14            2            1            5            1 
##          190          191          192          194          195          196          197          200 
##            6            1            1            2            2            4            2          147 
##          202          203          205          206          209          210          211          212 
##            1            2            2            1            2            5            1            2 
##          214          216          217          218          220          221          222          223 
##            1            2            1            5            6            3            2            2 
##          225          227          228          230          231          232          233          235 
##            1            3            1            8            1            1            1            6 
##          236          237          238          240          242          245          246          247 
##            1            1            1           10            1            1            2            1 
##          248          250          251          254          255          256          260          261 
##            1           61            1            4            3            5           11            1 
##          262          265          266          267          268          270          275          277 
##            3            2            1            1            2            8            2            1 
##          278          280          282          284          286          287          289          290 
##            1           21            1            2            1            1            3            4 
##          295          297          300          305          306          308          310          312 
##            2            2          165            1            1            1            2            3 
##          314          315          316          319          320          322          325          326 
##            1            2            2            1           11            1            7            1 
##          328          330          332          333          335          336          338          340 
##            1            3            1            1            2            2            1            6 
##          341          342          345          346          349          350          351          353 
##            1            1            3            1            1           56            3            1 
##          354          355          356          357          358          360          362          364 
##            2            1            2            2            1            6            1            1 
##          365          366          368          370          372          373          375          380 
##            5            1            2            4            1            1            3            7 
##          382          387          389          390          392          393          395          396 
##            1            2            2            3            1            1            1            1 
##          397          398          400          403          405          407          408          409 
##            1            1           73            1            1            1            1            1 
##          412          413          415          416          420          421          423          425 
##            1            1            1            1            3            1            1            2 
##          426          429          430          432          435          439          440          443 
##            1            1            5            1            1            1            2            1 
##          444          445          447          449          450          451          453          455 
##            2            1            1            1           17            2            1            1 
##          456          460          462          463          470          475          478          479 
##            1            2            1            1            1            2            1            1 
##          480          485          487          488          490          493          494          498 
##            6            1            1            1            1            1            1            1 
##          500          501          510          515          517          518          520          522 
##           91            1            1            1            1            1            5            1 
##          525          529          530          533          535          536          540          542 
##            1            2            1            1            1            1            4            1 
##          545          546          550          555          558          560          567          568 
##            3            1            4            2            1            3            1            1 
##          569          570          575          580          588          590          592          600 
##            1            2            1            4            1            2            1           65 
##          601          610          613          620          625          644          647          650 
##            1            1            1            3            1            1            1            5 
##          652          660          675          676          680          683          685          689 
##            1            3            1            1            1            1            2            1 
##          691          700          709          720          721          727          730          740 
##            1           49            1            1            1            1            1            1 
##          750          777          780          786          800          812          830          832 
##            6            1            5            3           28            1            1            1 
##          840          850          854          855          860          875          877          900 
##            1            3            1            1            2            1            1           18 
##          926          938          946          950          957          960          966          970 
##            1            1            2            2            1            1            1            1 
##          973          990          996          998         1000         1020         1026         1037 
##            1            1            1            1           36            1            1            1 
##         1040         1069         1080         1082         1100         1150         1200         1260 
##            1            1            1            1           10            1           17            1 
##         1270         1300         1387         1395         1400         1500         1550         1600 
##            1            9            1            1            2           12            1            2 
##         1700         1800         1900         2000         2003         2300         2400 2427 or more 
##            2            1            3            4            1            1            1           10 
##         <NA> 
##          351

percentile_99.5 <- floor(quantile(na.exclude(mydata$s9q41)[na.exclude(mydata$s9q41)!=999999], probs = c(0.995)))
mydata <- top_recode (variable="s9q41", break_point=percentile_99.5, missing=999999)
## [1] "Frequency table before encoding"
## s9q41. In the last 30 days how much did the household spend on Water ?  Sa nakalipas na
##    0    5    8   10   12   14   15   16   20   24   25   26   28   30   35   36   40   44   45   48   50   55 
##   22    2    1   15    2    1    2    2   68    1    8    1    3   21    1    1   21    1    6    3   33    1 
##   56   60   63   70   72   75   80   84   85   90   96  100  105  107  120  125  127  130  133  135  140  144 
##    2   28    1    4    2    5    7    2    1   20    1   47    1    1   22    7    1    7    2    2   12    1 
##  145  150  160  161  163  165  168  169  170  180  187  190  191  197  200  204  210  211  215  216  220  222 
##    3   48   16    1    8    1    4    1    2   17    1    1    1    1   62    3    2    2    1    2    4    1 
##  225  226  228  233  234  236  240  248  250  254  256  260  261  270  272  280  285  291  293  295  300  306 
##    4    4    1    1    2    2   17    2   23    1    1    1    1    2    1    5    2    2    1    1   63    1 
##  320  324  327  330  350  358  360  365  370  375  379  380  384  385  386  392  395  400  409  410  420  421 
##    6    1    1    2    8    1    4    1    1    3    1    2    2    1    1    1    1   22    1    1    3    1 
##  440  445  449  450  454  470  475  480  490  500  516  518  525  540  550  560  564  565  570  600  603  630 
##    1    1    1    8    1    1    1    2    1   28    1    1    1    2    1    3    1    1    1   17    1    1 
##  650  660  689  700  750  800  900  930 1000 1050 1100 1196 1200 1500 1800 2800 3600 6000 <NA> 
##    4    1    1    6    3    6    5    1    4    1    2    1    4    1    1    1    1    1 1399

## [1] "Frequency table after encoding"
## s9q41. In the last 30 days how much did the household spend on Water ?  Sa nakalipas na
##            0            5            8           10           12           14           15           16 
##           22            2            1           15            2            1            2            2 
##           20           24           25           26           28           30           35           36 
##           68            1            8            1            3           21            1            1 
##           40           44           45           48           50           55           56           60 
##           21            1            6            3           33            1            2           28 
##           63           70           72           75           80           84           85           90 
##            1            4            2            5            7            2            1           20 
##           96          100          105          107          120          125          127          130 
##            1           47            1            1           22            7            1            7 
##          133          135          140          144          145          150          160          161 
##            2            2           12            1            3           48           16            1 
##          163          165          168          169          170          180          187          190 
##            8            1            4            1            2           17            1            1 
##          191          197          200          204          210          211          215          216 
##            1            1           62            3            2            2            1            2 
##          220          222          225          226          228          233          234          236 
##            4            1            4            4            1            1            2            2 
##          240          248          250          254          256          260          261          270 
##           17            2           23            1            1            1            1            2 
##          272          280          285          291          293          295          300          306 
##            1            5            2            2            1            1           63            1 
##          320          324          327          330          350          358          360          365 
##            6            1            1            2            8            1            4            1 
##          370          375          379          380          384          385          386          392 
##            1            3            1            2            2            1            1            1 
##          395          400          409          410          420          421          440          445 
##            1           22            1            1            3            1            1            1 
##          449          450          454          470          475          480          490          500 
##            1            8            1            1            1            2            1           28 
##          516          518          525          540          550          560          564          565 
##            1            1            1            2            1            3            1            1 
##          570          600          603          630          650          660          689          700 
##            1           17            1            1            4            1            1            6 
##          750          800          900          930         1000         1050         1100         1196 
##            3            6            5            1            4            1            2            1 
##         1200 1355 or more         <NA> 
##            4            5         1399

percentile_99.5 <- floor(quantile(na.exclude(mydata$s9q42)[na.exclude(mydata$s9q42)!=999999], probs = c(0.995)))
mydata <- top_recode (variable="s9q42", break_point=percentile_99.5, missing=999999)
## [1] "Frequency table before encoding"
## s9q42. In the last 30 days how much did the household spend on House rent/mortgage ?  S
##    0   20   35   50  100  140  150  200  240  250  300  324  350  500  600  700  750  800  900 1000 1200 1250 
##    3    3    1    5    7    1    1    5    1    2    7    1    3    6    3    3    1    3    1   11    4    1 
## 1300 1500 1700 2000 2300 2500 3000 3500 5000 <NA> 
##    2    5    3    4    1    2    4    1    1 2200

## [1] "Frequency table after encoding"
## s9q42. In the last 30 days how much did the household spend on House rent/mortgage ?  S
##            0           20           35           50          100          140          150          200 
##            3            3            1            5            7            1            1            5 
##          240          250          300          324          350          500          600          700 
##            1            2            7            1            3            6            3            3 
##          750          800          900         1000         1200         1250         1300         1500 
##            1            3            1           11            4            1            2            5 
##         1700         2000         2300         2500         3000         3500 4287 or more         <NA> 
##            3            4            1            2            4            1            1         2200

percentile_99.5 <- floor(quantile(na.exclude(mydata$s9q43)[na.exclude(mydata$s9q43)!=999999], probs = c(0.995)))
mydata <- top_recode (variable="s9q43", break_point=percentile_99.5, missing=999999)
## [1] "Frequency table before encoding"
## s9q43. In the last 30 days how much did the household spend on Fixing home damage or im
##      0      5     10     24     28     30     35     50     60    100    120    125    150    200    250 
##      4      1      1      1      1      1      1      3      1      1      4      1      3      2      1 
##    300    350    400    416    450    500    520    540    600    675    700    720    800    850    856 
##      4      1      3      1      1     12      1      1      4      1      1      1      1      1      1 
##    900   1000   1100   1200   1250   1425   1500   1700   1800   1984   2000   2200   2300   2500   2700 
##      1     11      2      2      3      1      6      1      1      1     13      2      1      1      1 
##   2800   3000   3500   3720   4000   4050   5000   6000   6200   6300   7000   8000  10000  11000  12000 
##      2      6      3      1      7      1      8      2      1      1      2      4      4      1      1 
##  13000  14000  15000  18000  20000  23000  25000  26000  27000  30000  40000  50000  60000  70000  1e+05 
##      2      1      7      1      7      1      1      2      1      7      2      1      1      1      1 
## 220000  1e+06   <NA> 
##      1      1   2107

## [1] "Frequency table after encoding"
## s9q43. In the last 30 days how much did the household spend on Fixing home damage or im
##              0              5             10             24             28             30             35 
##              4              1              1              1              1              1              1 
##             50             60            100            120            125            150            200 
##              3              1              1              4              1              3              2 
##            250            300            350            400            416            450            500 
##              1              4              1              3              1              1             12 
##            520            540            600            675            700            720            800 
##              1              1              4              1              1              1              1 
##            850            856            900           1000           1100           1200           1250 
##              1              1              1             11              2              2              3 
##           1425           1500           1700           1800           1984           2000           2200 
##              1              6              1              1              1             13              2 
##           2300           2500           2700           2800           3000           3500           3720 
##              1              1              1              2              6              3              1 
##           4000           4050           5000           6000           6200           6300           7000 
##              7              1              8              2              1              1              2 
##           8000          10000          11000          12000          13000          14000          15000 
##              4              4              1              1              2              1              7 
##          18000          20000          23000          25000          26000          27000          30000 
##              1              7              1              1              2              1              7 
##          40000          50000          60000          70000          1e+05         220000 266800 or more 
##              2              1              1              1              1              1              1 
##           <NA> 
##           2107

percentile_99.5 <- floor(quantile(na.exclude(mydata$s9q44)[na.exclude(mydata$s9q44)!=999999], probs = c(0.995)))
mydata <- top_recode (variable="s9q44", break_point=percentile_99.5, missing=999999)
## [1] "Frequency table before encoding"
## s9q44. In the last 30 days how much did the household spend on Religious expenses or ot
##    0    1    2    5    7    8   10   15   17   20   25   28   30   35   40   45   50   55   60   70   75   80 
##   11    2    2   36    1    1   75   11    1  267    4    1   26    2   59    1   88    1   13    1    1   55 
##  100  108  110  120  125  140  150  160  180  200  208  210  240  250  260  300  320  400  450  500  508  520 
##   90    1    1    6    1    2   14    5    1   46    1    2    6    3    1    8    1   10    1    7    1    1 
##  600  680  700  800 1000 1080 2000 <NA> 
##    3    1    3    1    8    1    1 1410

## [1] "Frequency table after encoding"
## s9q44. In the last 30 days how much did the household spend on Religious expenses or ot
##            0            1            2            5            7            8           10           15 
##           11            2            2           36            1            1           75           11 
##           17           20           25           28           30           35           40           45 
##            1          267            4            1           26            2           59            1 
##           50           55           60           70           75           80          100          108 
##           88            1           13            1            1           55           90            1 
##          110          120          125          140          150          160          180          200 
##            1            6            1            2           14            5            1           46 
##          208          210          240          250          260          300          320          400 
##            1            2            6            3            1            8            1           10 
##          450          500          508          520          600          680          700          800 
##            1            7            1            1            3            1            3            1 
## 1000 or more         <NA> 
##           10         1410

percentile_99.5 <- floor(quantile(na.exclude(mydata$s9q45)[na.exclude(mydata$s9q45)!=999999], probs = c(0.995)))
mydata <- top_recode (variable="s9q45", break_point=percentile_99.5, missing=999999)
## [1] "Frequency table before encoding"
## s9q45. In the last 30 days how much did the household spend on Charitable donations ?  
##    0    1    5   10   12   15   20   22   25   30   35   36   38   40   50   58   60   70   75   80  100  120 
##    8    1   16   42    1    2  137    1    2   24    3    1    1   13   59    1    5    3    1   14   47    3 
##  150  180  200  250  280  300  400  500  600 1000 1500 <NA> 
##    6    2   12    2    1    3    1    5    2    5    1 1871

## [1] "Frequency table after encoding"
## s9q45. In the last 30 days how much did the household spend on Charitable donations ?  
##            0            1            5           10           12           15           20           22 
##            8            1           16           42            1            2          137            1 
##           25           30           35           36           38           40           50           58 
##            2           24            3            1            1           13           59            1 
##           60           70           75           80          100          120          150          180 
##            5            3            1           14           47            3            6            2 
##          200          250          280          300          400          500          600 1000 or more 
##           12            2            1            3            1            5            2            6 
##         <NA> 
##         1871

percentile_99.5 <- floor(quantile(na.exclude(mydata$s9q46)[na.exclude(mydata$s9q46)!=999999], probs = c(0.995)))
mydata <- top_recode (variable="s9q46", break_point=percentile_99.5, missing=999999)
## [1] "Frequency table before encoding"
## s9q46. In the last 30 days how much did the household spend on Weddings ?  Sa nakalipas
##     0    20    50    60    70    80    90   100   120   150   200   220   250   300   350   500   700   850 
##     2     4     5     2     2     1     1    39     3     9    31     1     4    12     3    13     2     1 
##  1000  1200  1500  1700  2000  2500  3000  5000  7000 15000 25000  <NA> 
##     3     1     2     1     4     1     2     3     2     3     2  2137

## [1] "Frequency table after encoding"
## s9q46. In the last 30 days how much did the household spend on Weddings ?  Sa nakalipas
##             0            20            50            60            70            80            90 
##             2             4             5             2             2             1             1 
##           100           120           150           200           220           250           300 
##            39             3             9            31             1             4            12 
##           350           500           700           850          1000          1200          1500 
##             3            13             2             1             3             1             2 
##          1700          2000          2500          3000          5000          7000         15000 
##             1             4             1             2             3             2             3 
## 25000 or more          <NA> 
##             2          2137

percentile_99.5 <- floor(quantile(na.exclude(mydata$s9q47)[na.exclude(mydata$s9q47)!=999999], probs = c(0.995)))
mydata <- top_recode (variable="s9q47", break_point=percentile_99.5, missing=999999)
## [1] "Frequency table before encoding"
## s9q47. In the last 30 days how much did the household spend on Funerals (including outs
##      0      2      5     10     18     20     25     30     32     35     40     45     50     55     60 
##      2      1      3     23      1     40      3      8      1      1     13      1     55      1      4 
##     70     85    100    105    120    150    160    200    208    250    300    320    400    500    600 
##      1      1     54      1      1      7      1     24      1      1      7      1      3     15      2 
##    700    900   1000   1500   2000   2064   2500   3500   5000  10000  12000  18000  20000  40000  60000 
##      1      1      3      2      3      1      1      1      1      2      1      1      1      1      1 
##  87000  1e+05 160000   <NA> 
##      1      1      1   1995

## [1] "Frequency table after encoding"
## s9q47. In the last 30 days how much did the household spend on Funerals (including outs
##             0             2             5            10            18            20            25 
##             2             1             3            23             1            40             3 
##            30            32            35            40            45            50            55 
##             8             1             1            13             1            55             1 
##            60            70            85           100           105           120           150 
##             4             1             1            54             1             1             7 
##           160           200           208           250           300           320           400 
##             1            24             1             1             7             1             3 
##           500           600           700           900          1000          1500          2000 
##            15             2             1             1             3             2             3 
##          2064          2500          3500          5000         10000         12000         18000 
##             1             1             1             1             2             1             1 
##         20000         40000         60000         87000 93500 or more          <NA> 
##             1             1             1             1             2          1995

percentile_99.5 <- floor(quantile(na.exclude(mydata$s9q48)[na.exclude(mydata$s9q48)!=999999], probs = c(0.995)))
mydata <- top_recode (variable="s9q48", break_point=percentile_99.5, missing=999999)
## [1] "Frequency table before encoding"
## s9q48. In the last 30 days how much did the household spend on School/college fees, uni
##     0     2    10    11    12    14    15    19    20    24    25    28    30    35    40    50    52    55 
##    20     1     3     2     3     1     2     1    15     1     3     1    12     2     8    16     1     1 
##    59    60    63    70    72    73    75    80    88    95    96   100   110   111   115   120   125   130 
##     1    11     1     4     2     1     4     6     1     2     1    61     1     1     1     5     1     2 
##   135   138   140   145   150   160   170   175   179   180   198   200   202   213   220   225   230   236 
##     1     1     3     1    36     6     4     3     1     7     1    45     1     1     1     1     3     1 
##   240   250   265   270   275   278   280   286   288   290   295   300   320   325   326   330   335   340 
##     2    14     1     2     2     1     4     1     1     2     1    51     2     1     1     1     1     1 
##   350   355   358   360   370   375   380   390   400   410   420   430   450   460   470   475   480   485 
##    14     1     2     2     1     1     3     1    25     2     1     1     5     3     1     1     1     1 
##   500   506   545   547   550   560   561   566   569   570   580   600   620   650   665   670   672   675 
##    75     1     1     1     2     4     1     1     1     1     1    18     2     2     1     1     1     1 
##   680   690   694   700   708   720   740   750   770   775   800   812   820   825   850   890   900   905 
##     2     1     1    20     1     1     1     2     1     1    12     1     1     1     2     1     9     1 
##   945   950   960  1000  1040  1050  1060  1100  1200  1298  1300  1320  1450  1500  1520  1535  1550  1600 
##     1     1     1    43     1     5     1     4    11     1     4     1     1    17     1     1     1     1 
##  1700  1732  1740  1750  1800  1880  1950  2000  2100  2120  2200  2250  2300  2350  2400  2450  2500  2600 
##     1     1     1     1     3     1     1    17     1     1     1     1     3     1     3     1     5     1 
##  2700  2900  3000  3050  3100  3500  4000  4100  4750  5000  5200  6000  6610  7000  7250  8500  9000  9600 
##     1     1    10     1     1     3     1     1     1     5     1     2     1     1     1     1     2     1 
## 10000 17000 18000 22960 35000  <NA> 
##     4     1     1     1     1  1468

## [1] "Frequency table after encoding"
## s9q48. In the last 30 days how much did the household spend on School/college fees, uni
##             0             2            10            11            12            14            15 
##            20             1             3             2             3             1             2 
##            19            20            24            25            28            30            35 
##             1            15             1             3             1            12             2 
##            40            50            52            55            59            60            63 
##             8            16             1             1             1            11             1 
##            70            72            73            75            80            88            95 
##             4             2             1             4             6             1             2 
##            96           100           110           111           115           120           125 
##             1            61             1             1             1             5             1 
##           130           135           138           140           145           150           160 
##             2             1             1             3             1            36             6 
##           170           175           179           180           198           200           202 
##             4             3             1             7             1            45             1 
##           213           220           225           230           236           240           250 
##             1             1             1             3             1             2            14 
##           265           270           275           278           280           286           288 
##             1             2             2             1             4             1             1 
##           290           295           300           320           325           326           330 
##             2             1            51             2             1             1             1 
##           335           340           350           355           358           360           370 
##             1             1            14             1             2             2             1 
##           375           380           390           400           410           420           430 
##             1             3             1            25             2             1             1 
##           450           460           470           475           480           485           500 
##             5             3             1             1             1             1            75 
##           506           545           547           550           560           561           566 
##             1             1             1             2             4             1             1 
##           569           570           580           600           620           650           665 
##             1             1             1            18             2             2             1 
##           670           672           675           680           690           694           700 
##             1             1             1             2             1             1            20 
##           708           720           740           750           770           775           800 
##             1             1             1             2             1             1            12 
##           812           820           825           850           890           900           905 
##             1             1             1             2             1             9             1 
##           945           950           960          1000          1040          1050          1060 
##             1             1             1            43             1             5             1 
##          1100          1200          1298          1300          1320          1450          1500 
##             4            11             1             4             1             1            17 
##          1520          1535          1550          1600          1700          1732          1740 
##             1             1             1             1             1             1             1 
##          1750          1800          1880          1950          2000          2100          2120 
##             1             3             1             1            17             1             1 
##          2200          2250          2300          2350          2400          2450          2500 
##             1             1             3             1             3             1             5 
##          2600          2700          2900          3000          3050          3100          3500 
##             1             1             1            10             1             1             3 
##          4000          4100          4750          5000          5200          6000          6610 
##             1             1             1             5             1             2             1 
##          7000          7250          8500          9000          9600 10000 or more          <NA> 
##             1             1             1             2             1             8          1468

percentile_99.5 <- floor(quantile(na.exclude(mydata$s9q49)[na.exclude(mydata$s9q49)!=999999], probs = c(0.995)))
mydata <- top_recode (variable="s9q49", break_point=percentile_99.5, missing=999999)
## [1] "Frequency table before encoding"
## s9q49. In the last 30 days how much did the household spend on Medical expenses, (inclu
##      0      5      6     10     12     14     15     16     18     20     24     25     26     28     30 
##     16      2      4     12      1      2      3      1      2     21      5      1      2      2     11 
##     32     33     34     35     36     38     40     42     44     45     46     50     51     52     53 
##      2      1      1      2      3      1      5      2      1      3      2     18      1      1      1 
##     55     59     60     62     63     64     65     66     67     68     70     72     75     80     87 
##      2      2      1      1      1      2      2      1      1      1      7      1      2      4      1 
##     88     89     90     92     95     99    100    103    105    108    110    113    116    120    124 
##      1      1      5      2      2      2     28      1      1      1      2      2      1     11      1 
##    125    127    130    135    136    138    140    142    150    154    156    160    166    170    175 
##      1      1      3      1      1      1      5      1     18      1      1      3      1      4      1 
##    180    188    190    200    208    210    212    215    220    222    224    225    230    232    233 
##      2      1      2     36      1      1      1      1      2      1      1      1      1      1      1 
##    234    236    240    242    243    250    252    270    275    278    280    283    289    290    300 
##      1      1      2      1      1     12      1      1      3      1      2      1      2      1     26 
##    305    308    310    320    324    325    330    335    350    356    358    359    360    375    376 
##      1      1      2      2      1      1      1      1      8      1      1      1      1      2      1 
##    378    380    400    404    410    423    429    440    450    455    470    475    476    480    490 
##      1      1     17      1      1      1      1      1      7      1      4      1      1      2      3 
##    496    500    508    512    520    524    530    531    540    550    555    557    560    568    580 
##      1     44      1      1      2      1      1      1      4      5      1      1      2      1      1 
##    596    600    630    635    645    650    700    710    724    749    750    756    760    770    773 
##      1     10      1      1      1      8     14      1      1      1      4      1      1      1      1 
##    790    800    814    825    834    848    849    850    855    880    900    910    925    928    950 
##      1      7      1      1      1      1      1      1      1      1      6      2      1      1      1 
##    965    975    980   1000   1020   1030   1045   1046   1050   1055   1090   1100   1107   1111   1120 
##      1      1      1     50      1      1      1      1      2      1      1      5      1      1      2 
##   1134   1140   1145   1150   1200   1230   1233   1250   1270   1300   1310   1330   1350   1365   1400 
##      1      1      1      1      8      1      1      1      1      3      1      1      2      1      1 
##   1420   1490   1500   1550   1572   1600   1670   1700   1710   1790   1800   1825   1830   1850   1889 
##      1      1     31      1      1      4      1      1      1      2      2      1      1      1      1 
##   1900   1950   1960   2000   2015   2025   2028   2080   2150   2163   2200   2232   2250   2270   2300 
##      1      1      1     20      1      1      1      2      2      1      2      1      1      1      1 
##   2400   2500   2600   2625   2650   2700   2710   2732   2750   2800   2835   3000   3010   3020   3096 
##      2     10      2      1      1      3      1      1      1      1      1     16      1      1      1 
##   3100   3140   3185   3300   3400   3500   3580   3600   4000   4050   4200   4300   4440   4500   4552 
##      1      1      1      2      1      3      1      1     10      1      1      1      1      1      1 
##   4690   4716   4800   4820   5000   5100   5200   5250   5400   5500   5550   5800   6000   6500   7000 
##      1      1      1      1     18      1      1      1      1      1      2      1      3      2      5 
##   7120   7500   7548   7710   7860   8000   8200   8500   8663   8766   9000   9189   9500  10000  10234 
##      1      2      1      1      1      3      1      1      1      1      2      1      1      5      1 
##  10700  11000  11610  11980  12000  13000  14300  15000  18500  20000  21006  22000  22080  27360  27500 
##      1      1      1      1      1      1      1      3      1      3      1      2      1      1      1 
##  33500  35000  50000  70000  1e+05 134000   <NA> 
##      1      1      1      1      1      1   1375

## [1] "Frequency table after encoding"
## s9q49. In the last 30 days how much did the household spend on Medical expenses, (inclu
##             0             5             6            10            12            14            15 
##            16             2             4            12             1             2             3 
##            16            18            20            24            25            26            28 
##             1             2            21             5             1             2             2 
##            30            32            33            34            35            36            38 
##            11             2             1             1             2             3             1 
##            40            42            44            45            46            50            51 
##             5             2             1             3             2            18             1 
##            52            53            55            59            60            62            63 
##             1             1             2             2             1             1             1 
##            64            65            66            67            68            70            72 
##             2             2             1             1             1             7             1 
##            75            80            87            88            89            90            92 
##             2             4             1             1             1             5             2 
##            95            99           100           103           105           108           110 
##             2             2            28             1             1             1             2 
##           113           116           120           124           125           127           130 
##             2             1            11             1             1             1             3 
##           135           136           138           140           142           150           154 
##             1             1             1             5             1            18             1 
##           156           160           166           170           175           180           188 
##             1             3             1             4             1             2             1 
##           190           200           208           210           212           215           220 
##             2            36             1             1             1             1             2 
##           222           224           225           230           232           233           234 
##             1             1             1             1             1             1             1 
##           236           240           242           243           250           252           270 
##             1             2             1             1            12             1             1 
##           275           278           280           283           289           290           300 
##             3             1             2             1             2             1            26 
##           305           308           310           320           324           325           330 
##             1             1             2             2             1             1             1 
##           335           350           356           358           359           360           375 
##             1             8             1             1             1             1             2 
##           376           378           380           400           404           410           423 
##             1             1             1            17             1             1             1 
##           429           440           450           455           470           475           476 
##             1             1             7             1             4             1             1 
##           480           490           496           500           508           512           520 
##             2             3             1            44             1             1             2 
##           524           530           531           540           550           555           557 
##             1             1             1             4             5             1             1 
##           560           568           580           596           600           630           635 
##             2             1             1             1            10             1             1 
##           645           650           700           710           724           749           750 
##             1             8            14             1             1             1             4 
##           756           760           770           773           790           800           814 
##             1             1             1             1             1             7             1 
##           825           834           848           849           850           855           880 
##             1             1             1             1             1             1             1 
##           900           910           925           928           950           965           975 
##             6             2             1             1             1             1             1 
##           980          1000          1020          1030          1045          1046          1050 
##             1            50             1             1             1             1             2 
##          1055          1090          1100          1107          1111          1120          1134 
##             1             1             5             1             1             2             1 
##          1140          1145          1150          1200          1230          1233          1250 
##             1             1             1             8             1             1             1 
##          1270          1300          1310          1330          1350          1365          1400 
##             1             3             1             1             2             1             1 
##          1420          1490          1500          1550          1572          1600          1670 
##             1             1            31             1             1             4             1 
##          1700          1710          1790          1800          1825          1830          1850 
##             1             1             2             2             1             1             1 
##          1889          1900          1950          1960          2000          2015          2025 
##             1             1             1             1            20             1             1 
##          2028          2080          2150          2163          2200          2232          2250 
##             1             2             2             1             2             1             1 
##          2270          2300          2400          2500          2600          2625          2650 
##             1             1             2            10             2             1             1 
##          2700          2710          2732          2750          2800          2835          3000 
##             3             1             1             1             1             1            16 
##          3010          3020          3096          3100          3140          3185          3300 
##             1             1             1             1             1             1             2 
##          3400          3500          3580          3600          4000          4050          4200 
##             1             3             1             1            10             1             1 
##          4300          4440          4500          4552          4690          4716          4800 
##             1             1             1             1             1             1             1 
##          4820          5000          5100          5200          5250          5400          5500 
##             1            18             1             1             1             1             1 
##          5550          5800          6000          6500          7000          7120          7500 
##             2             1             3             2             5             1             2 
##          7548          7710          7860          8000          8200          8500          8663 
##             1             1             1             3             1             1             1 
##          8766          9000          9189          9500         10000         10234         10700 
##             1             2             1             1             5             1             1 
##         11000         11610         11980         12000         13000         14300         15000 
##             1             1             1             1             1             1             3 
##         18500         20000         21006         22000         22080         27360         27500 
##             1             3             1             2             1             1             1 
##         33500 34099 or more          <NA> 
##             1             5          1375

percentile_99.5 <- floor(quantile(na.exclude(mydata$s9q50)[na.exclude(mydata$s9q50)!=999999], probs = c(0.995)))
mydata <- top_recode (variable="s9q50", break_point=percentile_99.5, missing=999999)
## [1] "Frequency table before encoding"
## s9q50. In the last 30 days how much did the household spend on Household durables (read
##     0    20    25    30    35    37    38    40    42    45    48    50    52    56    58    60    65    70 
##     5     6     1     6     8     1     2     7     1     8     1    21     1     1     1     9     2     5 
##    73    75    80    85    90    95   100   102   110   115   120   125   130   135   140   150   160   170 
##     1     1     6     2     5     1    25     1     1     1    12     2     4     1     3    11     4     1 
##   175   180   190   195   200   205   210   220   235   240   241   250   257   260   300   332   337   350 
##     1     2     1     2    18     1     1     1     1     2     1     8     1     1    12     1     1     5 
##   352   380   385   400   414   450   470   500   540   600   620   700   720   750   800   860   900   920 
##     1     1     1     4     1     2     2    12     1     2     1     3     1     1     1     1     2     1 
##   999  1000  1100  1270  1500  1680  1900  2100  2700  3000  3600  5000  5495  5500  6000 11000 12000  <NA> 
##     1     3     1     1     2     1     1     1     1     2     1     1     1     1     1     1     1  2009

## [1] "Frequency table after encoding"
## s9q50. In the last 30 days how much did the household spend on Household durables (read
##            0           20           25           30           35           37           38           40 
##            5            6            1            6            8            1            2            7 
##           42           45           48           50           52           56           58           60 
##            1            8            1           21            1            1            1            9 
##           65           70           73           75           80           85           90           95 
##            2            5            1            1            6            2            5            1 
##          100          102          110          115          120          125          130          135 
##           25            1            1            1           12            2            4            1 
##          140          150          160          170          175          180          190          195 
##            3           11            4            1            1            2            1            2 
##          200          205          210          220          235          240          241          250 
##           18            1            1            1            1            2            1            8 
##          257          260          300          332          337          350          352          380 
##            1            1           12            1            1            5            1            1 
##          385          400          414          450          470          500          540          600 
##            1            4            1            2            2           12            1            2 
##          620          700          720          750          800          860          900          920 
##            1            3            1            1            1            1            2            1 
##          999         1000         1100         1270         1500         1680         1900         2100 
##            1            3            1            1            2            1            1            1 
##         2700         3000         3600         5000         5495         5500         6000 8849 or more 
##            1            2            1            1            1            1            1            2 
##         <NA> 
##         2009

percentile_99.5 <- floor(quantile(na.exclude(mydata$s9q51)[na.exclude(mydata$s9q51)!=999999], probs = c(0.995)))
mydata <- top_recode (variable="s9q51", break_point=percentile_99.5, missing=999999)
## [1] "Frequency table before encoding"
## s9q51. In the last 30 days how much did the household spend on Dowry ?  Sa nakalipas na
##  500 <NA> 
##    1 2295

## [1] "Frequency table after encoding"
## s9q51. In the last 30 days how much did the household spend on Dowry ?  Sa nakalipas na
## 500 or more        <NA> 
##           1        2295

percentile_99.5 <- floor(quantile(na.exclude(mydata$s9q52)[na.exclude(mydata$s9q52)!=999999], probs = c(0.995)))
mydata <- top_recode (variable="s9q52", break_point=percentile_99.5, missing=999999)
## [1] "Frequency table before encoding"
## s9q52. In the last 30 days how much did the household spend on Fees paid to barangay of
##    0    5    8   10   11   12   15   16   18   20   21   22   25   30   35   38   40   41   45   50   55   60 
##    4    3    2    5    1    1    6    1    1   10    1    1    8   15   18    2   11    1    4   23    2    3 
##   65   70   75   78   80   85   90   95   96  100  105  120  130  135  140  150  155  160  200  215  230  250 
##    6    7    1    1    4    2    1    1    1   19    2    2    1    2    2    6    1    1    4    1    1    4 
##  300  480  500  600  700 1000 3000 <NA> 
##    3    1    3    1    1    2    1 2091

## [1] "Frequency table after encoding"
## s9q52. In the last 30 days how much did the household spend on Fees paid to barangay of
##            0            5            8           10           11           12           15           16 
##            4            3            2            5            1            1            6            1 
##           18           20           21           22           25           30           35           38 
##            1           10            1            1            8           15           18            2 
##           40           41           45           50           55           60           65           70 
##           11            1            4           23            2            3            6            7 
##           75           78           80           85           90           95           96          100 
##            1            1            4            2            1            1            1           19 
##          105          120          130          135          140          150          155          160 
##            2            2            1            2            2            6            1            1 
##          200          215          230          250          300          480          500          600 
##            4            1            1            4            3            1            3            1 
##          700 1000 or more         <NA> 
##            1            3         2091

percentile_99.5 <- floor(quantile(na.exclude(mydata$s9q73)[na.exclude(mydata$s9q73)!=999999], probs = c(0.995)))
mydata <- top_recode (variable="s9q73", break_point=percentile_99.5, missing=999999)
## [1] "Frequency table before encoding"
## s9q73. In the last 12 months did you spend any money on other expenses greater than PHP
##   0. No 1. Yes     <NA> 
##    1936     358       2

## [1] "Frequency table after encoding"
## s9q73. In the last 12 months did you spend any money on other expenses greater than PHP
##     0. No 1 or more      <NA> 
##      1936       358         2

percentile_99.5 <- floor(quantile(na.exclude(mydata$s9q75)[na.exclude(mydata$s9q75)!=999999], probs = c(0.995)))
mydata <- top_recode (variable="s9q75", break_point=percentile_99.5, missing=999999)
## [1] "Frequency table before encoding"
## s9q75. How much did you spend on these other expenses in total in the last 12 months?  
##      0    500    650   1000   1002   1008   1026   1050   1100   1121   1150   1180   1200   1250   1300 
##     51      1      1     16      1      1      1      1      7      1      2      1     16      1      5 
##   1400   1450   1500   1585   1600   1700   1750   1800   2000   2100   2300   2400   2500   2560   2600 
##      1      1     30      1      3      3      1      5     25      1      2      4      9      1      1 
##   2640   2700   2800   2875   2900   3000   3008   3100   3180   3200   3250   3500   3600   3680   3700 
##      1      5      5      1      2     22      1      1      1      1      1      6      1      1      1 
##   3800   4000   4200   4500   4750   4990   5000   5500   5715   6000   6500   7000   8000   9000  10000 
##      1     13      1      2      1      1     18      1      1      8      1      3      7      1      8 
##  12000  14000  15000  16000  16500  18000  18500  19200  20000  21000  23000  24000  25000  27360  28000 
##      4      1      3      3      1      1      1      1      3      1      1      2      1      1      1 
##  30000  32500  33500  34200  35000  47000  50000  60000 120000  2e+05 250000  5e+05  1e+06   <NA> 
##      2      1      1      1      1      1      1      2      1      1      1      1      1   1945

## [1] "Frequency table after encoding"
## s9q75. How much did you spend on these other expenses in total in the last 12 months?  
##              0            500            650           1000           1002           1008           1026 
##             51              1              1             16              1              1              1 
##           1050           1100           1121           1150           1180           1200           1250 
##              1              7              1              2              1             16              1 
##           1300           1400           1450           1500           1585           1600           1700 
##              5              1              1             30              1              3              3 
##           1750           1800           2000           2100           2300           2400           2500 
##              1              5             25              1              2              4              9 
##           2560           2600           2640           2700           2800           2875           2900 
##              1              1              1              5              5              1              2 
##           3000           3008           3100           3180           3200           3250           3500 
##             22              1              1              1              1              1              6 
##           3600           3680           3700           3800           4000           4200           4500 
##              1              1              1              1             13              1              2 
##           4750           4990           5000           5500           5715           6000           6500 
##              1              1             18              1              1              8              1 
##           7000           8000           9000          10000          12000          14000          15000 
##              3              7              1              8              4              1              3 
##          16000          16500          18000          18500          19200          20000          21000 
##              3              1              1              1              1              3              1 
##          23000          24000          25000          27360          28000          30000          32500 
##              1              2              1              1              1              2              1 
##          33500          34200          35000          47000          50000          60000         120000 
##              1              1              1              1              1              2              1 
##          2e+05         250000 312500 or more           <NA> 
##              1              1              2           1945

percentile_99.5 <- floor(quantile(na.exclude(mydata$s9q76)[na.exclude(mydata$s9q76)!=999999], probs = c(0.995)))
mydata <- top_recode (variable="s9q76", break_point=percentile_99.5, missing=999999)
## [1] "Frequency table before encoding"
## s9q76. Clothing for you?  Damit para sa iyo?
##    0    2    8   10   20   25   30   33   35   36   40   45   50   60   65   70   75   80   85   90   95  100 
## 2046    1    1    3   10    2   14    1    3    1    4    1   20    9    1    2    1    3    1    5    1   36 
##  110  120  130  150  160  170  180  190  200  220  235  250  260  270  280  300  305  320  330  350  360  380 
##    1    7    3   18    1    1    3    1   19    1    1   10    1    1    2   11    1    2    1    6    1    1 
##  400  460  495  500  700  800 1000 1500 1700 1950 2000 3000 <NA> 
##    3    1    1    6    6    3    6    1    1    1    2    2    4

## [1] "Frequency table after encoding"
## s9q76. Clothing for you?  Damit para sa iyo?
##            0            2            8           10           20           25           30           33 
##         2046            1            1            3           10            2           14            1 
##           35           36           40           45           50           60           65           70 
##            3            1            4            1           20            9            1            2 
##           75           80           85           90           95          100          110          120 
##            1            3            1            5            1           36            1            7 
##          130          150          160          170          180          190          200          220 
##            3           18            1            1            3            1           19            1 
##          235          250          260          270          280          300          305          320 
##            1           10            1            1            2           11            1            2 
##          330          350          360          380          400          460          495          500 
##            1            6            1            1            3            1            1            6 
##          700          800 1000 or more         <NA> 
##            6            3           13            4

percentile_99.5 <- floor(quantile(na.exclude(mydata$s9q77)[na.exclude(mydata$s9q77)!=999999], probs = c(0.995)))
mydata <- top_recode (variable="s9q77", break_point=percentile_99.5, missing=999999)
## [1] "Frequency table before encoding"
## s9q77. Clothing for your spouse/partner?  Damit para sa asawa/kinakasama mo?
##     0     2     8    10    15    20    25    30    33    35    36    40    45    50    55    60    70    75 
##  2121     1     1     1     1     3     2     2     1     2     1     3     1    13     1     4     1     1 
##    80    85    90   100   105   120   130   150   160   165   180   200   240   250   270   280   300   350 
##     3     1     2    33     1     1     1    16     1     1     2     8     1     5     1     4    10     4 
##   360   380   399   400   480   500   550   595   600   700   750  1000  1500  2000  2005  3000 65222  <NA> 
##     1     2     1     1     1     8     1     1     5     2     1     4     1     3     1     1     1     6

## [1] "Frequency table after encoding"
## s9q77. Clothing for your spouse/partner?  Damit para sa asawa/kinakasama mo?
##           0           2           8          10          15          20          25          30          33 
##        2121           1           1           1           1           3           2           2           1 
##          35          36          40          45          50          55          60          70          75 
##           2           1           3           1          13           1           4           1           1 
##          80          85          90         100         105         120         130         150         160 
##           3           1           2          33           1           1           1          16           1 
##         165         180         200         240         250         270         280         300         350 
##           1           2           8           1           5           1           4          10           4 
##         360         380         399         400         480         500         550         595         600 
##           1           2           1           1           1           8           1           1           5 
##         700 727 or more        <NA> 
##           2          12           6

percentile_99.5 <- floor(quantile(na.exclude(mydata$s9q78)[na.exclude(mydata$s9q78)!=999999], probs = c(0.995)))
mydata <- top_recode (variable="s9q78", break_point=percentile_99.5, missing=999999)
## [1] "Frequency table before encoding"
## s9q78. Clothing for the children?  Damit para sa mga bata?
##     0     2     8    20    25    30    35    40    50    60    66    70    75    80    85    90    95   100 
##  1536     1     3     8     1     8     7     2    16     5     1     6     1     3     1     3     1    51 
##   105   108   110   115   120   125   130   138   140   150   160   170   180   185   190   200   210   215 
##     1     1     2     1    10     1     8     1     1    27     4     2     9     1     2    60     1     1 
##   216   220   226   235   240   250   255   270   275   277   280   290   295   300   306   310   320   330 
##     1     2     1     1     2    23     1     2     1     1     4     1     1    66     1     1     3     3 
##   332   350   360   370   375   380   390   400   405   420   430   450   460   470   475   480   500   520 
##     1    19     5     1     1     7     1    21     1     1     2     9     2     1     1     1    89     3 
##   547   550   560   580   595   600   620   650   670   700   750   779   800   810   850   900   935  1000 
##     1     4     2     2     1    19     1     2     2    18     3     1    14     1     1     3     1    52 
##  1020  1040  1080  1100  1150  1200  1250  1400  1450  1500  1600  1880  1900  2000  2200  2300  2400  2500 
##     1     1     1     5     1     4     1     1     1    29     3     1     2    14     1     1     1     2 
##  2600  2660  2800  3000  3480  3500  4500  5000 12500  <NA> 
##     1     1     1    11     1     2     1     1     1    10

## [1] "Frequency table after encoding"
## s9q78. Clothing for the children?  Damit para sa mga bata?
##            0            2            8           20           25           30           35           40 
##         1536            1            3            8            1            8            7            2 
##           50           60           66           70           75           80           85           90 
##           16            5            1            6            1            3            1            3 
##           95          100          105          108          110          115          120          125 
##            1           51            1            1            2            1           10            1 
##          130          138          140          150          160          170          180          185 
##            8            1            1           27            4            2            9            1 
##          190          200          210          215          216          220          226          235 
##            2           60            1            1            1            2            1            1 
##          240          250          255          270          275          277          280          290 
##            2           23            1            2            1            1            4            1 
##          295          300          306          310          320          330          332          350 
##            1           66            1            1            3            3            1           19 
##          360          370          375          380          390          400          405          420 
##            5            1            1            7            1           21            1            1 
##          430          450          460          470          475          480          500          520 
##            2            9            2            1            1            1           89            3 
##          547          550          560          580          595          600          620          650 
##            1            4            2            2            1           19            1            2 
##          670          700          750          779          800          810          850          900 
##            2           18            3            1           14            1            1            3 
##          935         1000         1020         1040         1080         1100         1150         1200 
##            1           52            1            1            1            5            1            4 
##         1250         1400         1450         1500         1600         1880         1900         2000 
##            1            1            1           29            3            1            2           14 
##         2200         2300         2400         2500         2600         2660         2800 3000 or more 
##            1            1            1            2            1            1            1           17 
##         <NA> 
##           10

percentile_99.5 <- floor(quantile(na.exclude(mydata$s9q79)[na.exclude(mydata$s9q79)!=999999], probs = c(0.995)))
mydata <- top_recode (variable="s9q79", break_point=percentile_99.5, missing=999999)
## [1] "Frequency table before encoding"
## s9q79. Medical expenses for you?  Gastos pang medikal para sa iyo?
##      0      2      3      5      6      7     10     12     15     16     18     20     21     22     24 
##   1865      1      3      4      5      1      6      4      3      1      2     23      1      1      2 
##     25     26     28     30     32     33     36     40     45     48     50     52     54     55     60 
##      2      2      2     14      1      2      1      8      2      2     29      1      1      1      5 
##     64     65     70     72     75     80     90     96    100    105    113    116    120    135    143 
##      1      1      4      2      1      4      1      1     34      2      1      2      4      1      1 
##    150    175    180    189    190    200    210    220    228    240    250    275    300    320    333 
##     17      1      1      1      2     33      1      1      1      2      4      1     11      1      1 
##    350    357    375    390    400    450    465    470    480    490    500    530    550    596    600 
##      1      1      1      1      6      2      1      1      1      1     24      1      1      1      1 
##    650    700    730    749    750    770    800    850    900    975   1000   1020   1027   1200   1300 
##      2      4      1      1      3      1      3      2      2      1     22      1      1      4      1 
##   1450   1470   1500   1550   1710   1800   1950   2000   2080   2200   2400   2435   2600   2700   2800 
##      1      1     11      1      1      2      1      9      1      1      1      1      2      2      1 
##   3000   3100   3400   3600   4000   4200   4300   5000   5780   6003   7000   9600  10000  15000  70000 
##      7      1      1      1      3      1      1      4      1      1      2      1      2      1      1 
## 134000   <NA> 
##      1      5

## [1] "Frequency table after encoding"
## s9q79. Medical expenses for you?  Gastos pang medikal para sa iyo?
##            0            2            3            5            6            7           10           12 
##         1865            1            3            4            5            1            6            4 
##           15           16           18           20           21           22           24           25 
##            3            1            2           23            1            1            2            2 
##           26           28           30           32           33           36           40           45 
##            2            2           14            1            2            1            8            2 
##           48           50           52           54           55           60           64           65 
##            2           29            1            1            1            5            1            1 
##           70           72           75           80           90           96          100          105 
##            4            2            1            4            1            1           34            2 
##          113          116          120          135          143          150          175          180 
##            1            2            4            1            1           17            1            1 
##          189          190          200          210          220          228          240          250 
##            1            2           33            1            1            1            2            4 
##          275          300          320          333          350          357          375          390 
##            1           11            1            1            1            1            1            1 
##          400          450          465          470          480          490          500          530 
##            6            2            1            1            1            1           24            1 
##          550          596          600          650          700          730          749          750 
##            1            1            1            2            4            1            1            3 
##          770          800          850          900          975         1000         1020         1027 
##            1            3            2            2            1           22            1            1 
##         1200         1300         1450         1470         1500         1550         1710         1800 
##            4            1            1            1           11            1            1            2 
##         1950         2000         2080         2200         2400         2435         2600         2700 
##            1            9            1            1            1            1            2            2 
##         2800         3000         3100         3400         3600         4000         4200         4300 
##            1            7            1            1            1            3            1            1 
## 5000 or more         <NA> 
##           14            5

percentile_99.5 <- floor(quantile(na.exclude(mydata$s9q80)[na.exclude(mydata$s9q80)!=999999], probs = c(0.995)))
mydata <- top_recode (variable="s9q80", break_point=percentile_99.5, missing=999999)
## [1] "Frequency table before encoding"
## s9q80. Medical expenses for your spouse/partner?  Gastos pang medikal para sa asawa/kin
##      0      2      4      6     10     12     13     15     16     20     24     25     30     31     40 
##   1952      1      1      1      4      2      1      3      1     13      5      4      6      1      4 
##     42     45     50     52     58     60     63     64     66     67     70     80     90     99    100 
##      1      1     32      1      2      5      1      1      1      1      4      2      1      1     26 
##    108    112    120    132    138    144    150    160    176    180    200    240    245    250    252 
##      1      1      3      1      1      1      8      1      1      2     28      1      1      7      1 
##    280    300    325    330    345    350    360    400    430    500    600    700    725    735    750 
##      1     15      1      1      1      2      1      7      1     24      3      3      1      1      3 
##    773    800    900    910   1000   1050   1100   1200   1300   1400   1500   1600   1670   1800   2000 
##      1      2      3      1     17      1      1      2      1      1     15      1      1      2      8 
##   2150   2400   2500   3000   3100   3150   3300   3500   4000   5000   5280   5360   7000   7104   7500 
##      1      1      5      5      1      1      1      1      1      5      1      1      2      1      1 
##  10000  10300  30000  32000  1e+05 280000   <NA> 
##      1      1      1      1      1      1      3

## [1] "Frequency table after encoding"
## s9q80. Medical expenses for your spouse/partner?  Gastos pang medikal para sa asawa/kin
##            0            2            4            6           10           12           13           15 
##         1952            1            1            1            4            2            1            3 
##           16           20           24           25           30           31           40           42 
##            1           13            5            4            6            1            4            1 
##           45           50           52           58           60           63           64           66 
##            1           32            1            2            5            1            1            1 
##           67           70           80           90           99          100          108          112 
##            1            4            2            1            1           26            1            1 
##          120          132          138          144          150          160          176          180 
##            3            1            1            1            8            1            1            2 
##          200          240          245          250          252          280          300          325 
##           28            1            1            7            1            1           15            1 
##          330          345          350          360          400          430          500          600 
##            1            1            2            1            7            1           24            3 
##          700          725          735          750          773          800          900          910 
##            3            1            1            3            1            2            3            1 
##         1000         1050         1100         1200         1300         1400         1500         1600 
##           17            1            1            2            1            1           15            1 
##         1670         1800         2000         2150         2400         2500         3000         3100 
##            1            2            8            1            1            5            5            1 
##         3150         3300         3500         4000         5000 5151 or more         <NA> 
##            1            1            1            1            5           12            3

percentile_99.5 <- floor(quantile(na.exclude(mydata$s9q81)[na.exclude(mydata$s9q81)!=999999], probs = c(0.995)))
mydata <- top_recode (variable="s9q81", break_point=percentile_99.5, missing=999999)
## [1] "Frequency table before encoding"
## s9q81. Medical expenses and vaccinations for the children of the household?  Gastos pan
##     0     5     6     8    10    12    14    15    16    18    20    24    26    28    30    31    32    34 
##  1625     2     3     1    18     2     2     3     1     2    27     2     1     2    10     1     2     2 
##    35    36    38    39    40    42    45    46    47    48    50    52    54    55    57    58    59    60 
##     3     3     1     2     5     4     3     1     1     1    32     2     1     1     1     1     1     5 
##    62    64    68    70    72    75    77    78    80    85    90    92    95    99   100   103   105   106 
##     1     2     1     9     2     3     1     1     8     1     4     1     2     1    23     1     3     1 
##   108   110   111   115   120   125   129   130   140   150   160   170   174   182   188   190   200   205 
##     1     3     1     1    12     1     1     5     3    18     2     1     1     1     1     1    34     1 
##   212   215   220   224   225   244   248   250   260   270   275   278   288   290   300   308   310   314 
##     1     1     1     1     2     1     1     4     1     1     2     1     1     1    19     1     1     1 
##   324   331   335   338   350   360   378   380   390   393   400   412   423   425   450   455   460   470 
##     2     1     1     1     9     1     1     1     1     1    14     1     1     1     5     1     1     2 
##   480   490   500   530   535   540   550   568   580   600   630   635   645   650   698   700   710   746 
##     1     1    30     1     1     1     1     1     1    11     1     1     1     1     1     8     1     1 
##   750   800   830   834   880   900   925   941   965   975   980  1000  1025  1030  1055  1070  1080  1090 
##     3     5     1     1     1     4     1     1     1     1     1    28     1     1     1     1     1     1 
##  1100  1151  1152  1200  1230  1233  1281  1300  1315  1320  1350  1400  1470  1500  1550  1560  1600  1700 
##     4     1     1     5     1     1     1     2     1     1     1     1     1    19     1     1     2     2 
##  1750  1790  1800  1850  1900  2000  2040  2150  2167  2232  2300  2500  2516  2548  2580  2650  2700  2710 
##     1     1     2     1     1    23     1     1     1     1     1     5     1     1     1     1     1     2 
##  2800  3000  3010  3300  3500  3600  4000  4200  4300  4440  4500  4550  4600  4690  4800  5000  5250  5400 
##     1     5     1     1     4     1     7     2     1     1     1     1     1     1     1     4     1     1 
##  5800  6000  6500  7000  8000  8200  8550  8766  8900  9000  9200 10000 10120 10480 11000 11110 15000 20000 
##     1     2     1     3     3     1     1     1     1     1     1     4     1     1     1     1     2     3 
## 21000 24000 25000 50000  <NA> 
##     1     1     1     1     5

## [1] "Frequency table after encoding"
## s9q81. Medical expenses and vaccinations for the children of the household?  Gastos pan
##             0             5             6             8            10            12            14 
##          1625             2             3             1            18             2             2 
##            15            16            18            20            24            26            28 
##             3             1             2            27             2             1             2 
##            30            31            32            34            35            36            38 
##            10             1             2             2             3             3             1 
##            39            40            42            45            46            47            48 
##             2             5             4             3             1             1             1 
##            50            52            54            55            57            58            59 
##            32             2             1             1             1             1             1 
##            60            62            64            68            70            72            75 
##             5             1             2             1             9             2             3 
##            77            78            80            85            90            92            95 
##             1             1             8             1             4             1             2 
##            99           100           103           105           106           108           110 
##             1            23             1             3             1             1             3 
##           111           115           120           125           129           130           140 
##             1             1            12             1             1             5             3 
##           150           160           170           174           182           188           190 
##            18             2             1             1             1             1             1 
##           200           205           212           215           220           224           225 
##            34             1             1             1             1             1             2 
##           244           248           250           260           270           275           278 
##             1             1             4             1             1             2             1 
##           288           290           300           308           310           314           324 
##             1             1            19             1             1             1             2 
##           331           335           338           350           360           378           380 
##             1             1             1             9             1             1             1 
##           390           393           400           412           423           425           450 
##             1             1            14             1             1             1             5 
##           455           460           470           480           490           500           530 
##             1             1             2             1             1            30             1 
##           535           540           550           568           580           600           630 
##             1             1             1             1             1            11             1 
##           635           645           650           698           700           710           746 
##             1             1             1             1             8             1             1 
##           750           800           830           834           880           900           925 
##             3             5             1             1             1             4             1 
##           941           965           975           980          1000          1025          1030 
##             1             1             1             1            28             1             1 
##          1055          1070          1080          1090          1100          1151          1152 
##             1             1             1             1             4             1             1 
##          1200          1230          1233          1281          1300          1315          1320 
##             5             1             1             1             2             1             1 
##          1350          1400          1470          1500          1550          1560          1600 
##             1             1             1            19             1             1             2 
##          1700          1750          1790          1800          1850          1900          2000 
##             2             1             1             2             1             1            23 
##          2040          2150          2167          2232          2300          2500          2516 
##             1             1             1             1             1             5             1 
##          2548          2580          2650          2700          2710          2800          3000 
##             1             1             1             1             2             1             5 
##          3010          3300          3500          3600          4000          4200          4300 
##             1             1             4             1             7             2             1 
##          4440          4500          4550          4600          4690          4800          5000 
##             1             1             1             1             1             1             4 
##          5250          5400          5800          6000          6500          7000          8000 
##             1             1             1             2             1             3             3 
##          8200          8550          8766          8900          9000          9200         10000 
##             1             1             1             1             1             1             4 
##         10120 10318 or more          <NA> 
##             1            12             5

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("s9q42a",
                  "s9q43a",
                  "s9q44a",
                  "s9q45a",
                  "s9q46a",
                  "s9q47a",
                  "s9q48a",
                  "s9q49a",
                  "s9q51a",
                  "s9q52a",
                  "s9q1a",
                  "s9q2a",
                  "s9q3a",
                  "s9q4a",
                  "s9q5a",
                  "s9q6a",
                  "s9q7a",
                  "s9q8a",
                  "s9q9a",
                  "s9q9a",
                  "s9q9a",
                  "s9q9a",
                  "s9q9a",
                  "s9q9a",
                  "s9q9a",
                  "s9q9a",
                  "s9q9a",
                  "s9q9a",
                  "s9q9a",
                  "s9q9a",
                  "s9q9a",
                  "s9q9a",
                  "s9q9a",
                  "s9q9a",
                  "s9q9a")
capture_tables (indirect_PII)

# !!!No data with specific values. 

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("s9q1awhynoresponse",
               "s9q1whynoresponse",
               "s9q2awhynoresponse",
               "s9q2whynoresponse",
               "s9q3awhynoresponse",
               "s9q3whynoresponse",
               "s9q4awhynoresponse",
               "s9q4whynoresponse",
               "s9q5awhynoresponse",
               "s9q5whynoresponse",
               "s9q6awhynoresponse",
               "s9q6whynoresponse",
               "s9q7awhynoresponse",
               "s9q7whynoresponse",
               "s9q8awhynoresponse",
               "s9q8whynoresponse",
               "s9q9awhynoresponse",
               "s9q9whynoresponse",
               "s9q10awhynoresponse",
               "s9q10whynoresponse",
               "s9q11awhynoresponse",
               "s9q11whynoresponse",
               "s9q12awhynoresponse",
               "s9q12whynoresponse",
               "s9q13awhynoresponse",
               "s9q13whynoresponse",
               "s9q14awhynoresponse",
               "s9q15",
               "s9q14whynoresponse",
               "s9q15otherwhynoresponse",
               "s9q32awhynoresponse",
               "s9q32whynoresponse",
               "s9q33awhynoresponse",
               "s9q33whynoresponse",
               "s9q34awhynoresponse",
               "s9q34whynoresponse",
               "s9q35awhynoresponse",
               "s9q35whynoresponse",
               "s9q36awhynoresponse",
               "s9q36whynoresponse",
               "s9q37awhynoresponse",
               "s9q37whynoresponse",
               "s9q38awhynoresponse",
               "s9q38whynoresponse",
               "s9q39awhynoresponse",
               "s9q39whynoresponse",
               "s9q40awhynoresponse",
               "s9q40whynoresponse",
               "s9q41awhynoresponse",
               "s9q41whynoresponse",
               "s9q42awhynoresponse",
               "s9q42whynoresponse",
               "s9q43awhynoresponse",
               "s9q43whynoresponse",
               "s9q44awhynoresponse",
               "s9q44whynoresponse",
               "s9q45awhynoresponse",
               "s9q45whynoresponse",
               "s9q46awhynoresponse",
               "s9q46whynoresponse",
               "s9q47awhynoresponse",
               "s9q47whynoresponse",
               "s9q48awhynoresponse",
               "s9q48whynoresponse",
               "s9q49awhynoresponse",
               "s9q49whynoresponse",
               "s9q50awhynoresponse",
               "s9q50whynoresponse",
               "s9q51awhynoresponse",
               "s9q51whynoresponse",
               "s9q52awhynoresponse",
               "s9q52whynoresponse",
               "s9q74",
               "s9q73whynoresponse",
               "s9q75whynoresponse",
               "s9q76whynoresponse",
               "s9q77whynoresponse",
               "s9q78whynoresponse",
               "s9q79whynoresponse",
               "s9q80whynoresponse",
               "s9q81whynoresponse")

report_open (list_open_ends = open_ends)

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

mydata$s9q2whynoresponse[137] <- "[language]"
mydata$s9q5whynoresponse[63] <- "[language]"
mydata$s9q8whynoresponse[63] <- "[language]"
mydata$s9q14awhynoresponse[1088] <- "[language]"

mydata$s9q15[3] <- "[language]"
mydata$s9q15[19] <- "[language]"
mydata$s9q15[181] <- "[language]"
mydata$s9q15[183] <- "[language]"
mydata$s9q15[238] <- "[language]"
mydata$s9q15[541] <- "[language]"
mydata$s9q15[744] <- "[language]"
mydata$s9q15[1109] <- "[language]"
mydata$s9q15[1134] <- "[language]"
mydata$s9q15[1447] <- "[language]"
mydata$s9q15[1499] <- "[language]"
mydata$s9q15[1501] <- "[language]"
mydata$s9q15[1734] <- "[language]"

mydata$s9q32awhynoresponse[1102] <- "[name] is not informed how much his Son [name] is spending on load."
mydata$s9q40awhynoresponse[1294] <- "[person] is paying"

mydata$s9q74[176] <- "[amount redacted]"
mydata$s9q74[649] <- "Graduation fee and expenses of [name]. Uniform, shoes"
mydata$s9q74[884] <- "[amount redacted]"
mydata$s9q74[1109] <- "[amount redacted]"
mydata$s9q74[1175] <- "[amount redacted]"
mydata$s9q74[1268] <- "[amount redacted]"
mydata$s9q74[1355] <- "[amount redacted]"
mydata$s9q74[1859] <- "[amount redacted]"
mydata$s9q74[1874] <- "[amount redacted]"
mydata$s9q74[1961] <- "[amount redacted]"
mydata$s9q74[2007] <- "[amount redacted]"
mydata$s9q74[857] <- "[amount redacted] of rice"
mydata$s9q74[1569] <- "[amount redacted] for house materials"
mydata$s9q74[40] <- "[language]"
mydata$s9q74[507] <- "[language]"
mydata$s9q74[1054] <- "[language]"
mydata$s9q74[1096] <- "[language]"
mydata$s9q74[1111] <- "[language]"
mydata$s9q74[1443] <- "[language]"
mydata$s9q74[1461] <- "[language]"
mydata$s9q74[1472] <- "[language]"
mydata$s9q74[1501] <- "[language]"
mydata$s9q74[1735] <- "[language]"
mydata$s9q74[504] <- "Vaccine for [name]"
mydata$s9q74[665] <- "[illness] from her husband."
mydata$s9q74[1045] <- "Fare going to [city]"
mydata$s9q74[1187] <- "Hospitalization of [name]"
mydata$s9q74[1203] <- "Medicine, laboratory of Mother [name] and Son [name]"
mydata$s9q74[1333] <- "Fare transportation visiting her child in [city]"
mydata$s9q74[1395] <- "Medical expenses of her child who has [illness] and yhe other child who had [illness]"
mydata$s9q74[1752] <- "Hospitalization of [name] last July [year]."
mydata$s9q74[1853] <- "Hospitalization for [name]"
mydata$s9q74[1120] <- "Medicine of [name]"
mydata$s9q74[1049] <- "For Requirements and payment of her son studying in [small location]"

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)