rm(list=ls(all=t))

Setup filenames

filename <- "Section_8" # !!!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$s8q8_1)[na.exclude(mydata$s8q8_1)!=999999], probs = c(0.995)))
mydata <- top_recode (variable="s8q8_1", break_point=percentile_99.5, missing=999999)
## [1] "Frequency table before encoding"
## s8q8_1. How much was this start-up capital?  Magkano ang pangunang kapital na ito?
##      0     10     20     35     50     60     75     90    100    125    130    150    178    200    250 
##      3      1      1      1      3      1      1      1      6      1      1      5      1      8      3 
##    271    300    350    400    450    500    600    700    750    800    900   1000   1500   1600   1675 
##      1      7      1      2      2     36      3      4      1      2      1     45     16      2      1 
##   2000   2100   2500   2700   3000   3500   3700   4000   4500   4900   5000   5500   6000   6500   7000 
##     33      1      5      1     36      2      1      9      1      1     56      1      3      2      7 
##   7500   8000   8400  10000  11000  11760  12000  14000  15000  16000  20000  21000  21600  22000  25000 
##      1      1      1     27      1      1      1      4     10      1      7      2      1      1      2 
##  30000  39000  45408  47000  50000  53096  75000  76000  80000  85000  1e+05 150000   <NA> 
##      1      1      1      1      1      1      1      1      1      1      1      1   1903

## [1] "Frequency table after encoding"
## s8q8_1. How much was this start-up capital?  Magkano ang pangunang kapital na ito?
##             0            10            20            35            50            60            75 
##             3             1             1             1             3             1             1 
##            90           100           125           130           150           178           200 
##             1             6             1             1             5             1             8 
##           250           271           300           350           400           450           500 
##             3             1             7             1             2             2            36 
##           600           700           750           800           900          1000          1500 
##             3             4             1             2             1            45            16 
##          1600          1675          2000          2100          2500          2700          3000 
##             2             1            33             1             5             1            36 
##          3500          3700          4000          4500          4900          5000          5500 
##             2             1             9             1             1            56             1 
##          6000          6500          7000          7500          8000          8400         10000 
##             3             2             7             1             1             1            27 
##         11000         11760         12000         14000         15000         16000         20000 
##             1             1             1             4            10             1             7 
##         21000         21600         22000         25000         30000         39000         45408 
##             2             1             1             2             1             1             1 
##         47000         50000         53096         75000         76000         80000         85000 
##             1             1             1             1             1             1             1 
## 85600 or more          <NA> 
##             2          1903

percentile_99.5 <- floor(quantile(na.exclude(mydata$s8q9_1)[na.exclude(mydata$s8q9_1)!=999999], probs = c(0.995)))
mydata <- top_recode (variable="s8q9_1", break_point=percentile_99.5, missing=999999)
## [1] "Frequency table before encoding"
## s8q9_1. In the last 12 months what was spent on machinery or durable goods (e.g., tools,
##       0      50      60      65      66      85     100     105     120     130     150     195     200 
##     333       2       1       1       1       1       3       1       1       1       4       1       4 
##     250     255     260     292     300     360     370     380     420     450     500     510     560 
##       2       1       1       1       5       1       1       1       1       2      14       1       1 
##     600     620     708     750     800     840     850     900     960    1000    1111    1160    1350 
##       6       1       1       2       2       2       1       1       1       9       1       1       1 
##    1400    1500    1600    1850    2000    2400    2500    2640    3000    3060    3500    3900    3984 
##       1       5       1       1       9       1       3       1       9       2       3       1       1 
##    4000    4032    4045    4200    4320    4500    4900    5000    5070    5200    6720    7000   10000 
##       2       1       1       1       1       1       1      10       1       1       1       3       4 
##   12400   13500   13600   14000   14400   15000   16000   20000   21000   22000   40000   41900   48000 
##       1       1       1       1       1       2       1       2       1       1       1       1       1 
##   50000   50250   85000 1.2e+07    <NA> 
##       1       1       1       1    1796

## [1] "Frequency table after encoding"
## s8q9_1. In the last 12 months what was spent on machinery or durable goods (e.g., tools,
##             0            50            60            65            66            85           100 
##           333             2             1             1             1             1             3 
##           105           120           130           150           195           200           250 
##             1             1             1             4             1             4             2 
##           255           260           292           300           360           370           380 
##             1             1             1             5             1             1             1 
##           420           450           500           510           560           600           620 
##             1             2            14             1             1             6             1 
##           708           750           800           840           850           900           960 
##             1             2             2             2             1             1             1 
##          1000          1111          1160          1350          1400          1500          1600 
##             9             1             1             1             1             5             1 
##          1850          2000          2400          2500          2640          3000          3060 
##             1             9             1             3             1             9             2 
##          3500          3900          3984          4000          4032          4045          4200 
##             3             1             1             2             1             1             1 
##          4320          4500          4900          5000          5070          5200          6720 
##             1             1             1            10             1             1             1 
##          7000         10000         12400         13500         13600         14000         14400 
##             3             4             1             1             1             1             1 
##         15000         16000         20000         21000         22000         40000         41900 
##             2             1             2             1             1             1             1 
##         48000         50000 50126 or more          <NA> 
##             1             1             3          1796

percentile_99.5 <- floor(quantile(na.exclude(mydata$s8q12_1)[na.exclude(mydata$s8q12_1)!=999999], probs = c(0.995)))
mydata <- top_recode (variable="s8q12_1", break_point=percentile_99.5, missing=999999)
## [1] "Frequency table before encoding"
## s8q12_1. Electricity  Kuryente
##      0      1      2     11     18     20     30     40     50    100    119    125    200    240    250 
##    431      1      1      1      1      3      4      1      3      1      1      1      1      2      1 
##    300    400    500    600    755    756    800    900   1000   1100   1200   1500   1800   2000   2400 
##      3      1      3      6      1      1      2      1      1      1      2      1      1      1      3 
##   2500   3000   3600   4000   6000   6800   7200   8400  15000  33600  34800  36000  37200 840000   <NA> 
##      1      1      3      1      4      1      2      1      1      1      1      1      1      1   1795

## [1] "Frequency table after encoding"
## s8q12_1. Electricity  Kuryente
##             0             1             2            11            18            20            30 
##           431             1             1             1             1             3             4 
##            40            50           100           119           125           200           240 
##             1             3             1             1             1             1             2 
##           250           300           400           500           600           755           756 
##             1             3             1             3             6             1             1 
##           800           900          1000          1100          1200          1500          1800 
##             2             1             1             1             2             1             1 
##          2000          2400          2500          3000          3600          4000          6000 
##             1             3             1             1             3             1             4 
##          6800          7200          8400         15000         33600         34800 35400 or more 
##             1             2             1             1             1             1             3 
##          <NA> 
##          1795

percentile_99.5 <- floor(quantile(na.exclude(mydata$s8q13_1)[na.exclude(mydata$s8q13_1)!=999999], probs = c(0.995)))
mydata <- top_recode (variable="s8q13_1", break_point=percentile_99.5, missing=999999)
## [1] "Frequency table before encoding"
## s8q13_1. Salaries/Wages  Pasahod/Suweldo 
##      0      1      3    100    200   1500   4320   4800  10000  14400  20000  72000  76800  87600 360000 
##    486      1      1      1      1      1      1      1      1      1      1      1      1      1      1 
## 528000   <NA> 
##      1   1795

## [1] "Frequency table after encoding"
## s8q13_1. Salaries/Wages  Pasahod/Suweldo 
##             0             1             3           100           200          1500          4320 
##           486             1             1             1             1             1             1 
##          4800         10000         14400         20000         72000         76800 82200 or more 
##             1             1             1             1             1             1             3 
##          <NA> 
##          1795

percentile_99.5 <- floor(quantile(na.exclude(mydata$s8q14_1)[na.exclude(mydata$s8q14_1)!=999999], probs = c(0.995)))
mydata <- top_recode (variable="s8q14_1", break_point=percentile_99.5, missing=999999)
## [1] "Frequency table before encoding"
## s8q14_1. Water  Tubig
##      0      1      2      8     20     30     50     60     80     90    120    200    226    240    300 
##    471      1      1      1      2      1      1      1      1      2      1      3      1      1      2 
##    350    360    480    720   1250   1680   1728   1825   2400   3600 144000   <NA> 
##      1      1      1      1      1      1      1      1      1      2      1   1794

## [1] "Frequency table after encoding"
## s8q14_1. Water  Tubig
##            0            1            2            8           20           30           50           60 
##          471            1            1            1            2            1            1            1 
##           80           90          120          200          226          240          300          350 
##            1            2            1            3            1            1            2            1 
##          360          480          720         1250         1680         1728         1825         2400 
##            1            1            1            1            1            1            1            1 
## 2994 or more         <NA> 
##            3         1794

percentile_99.5 <- floor(quantile(na.exclude(mydata$s8q15_1)[na.exclude(mydata$s8q15_1)!=999999], probs = c(0.995)))
mydata <- top_recode (variable="s8q15_1", break_point=percentile_99.5, missing=999999)
## [1] "Frequency table before encoding"
## s8q15_1. Transport  Transportasyon
##      0      1     14     16     20     35     40     42     50     56     80     90     95    100    110 
##    265      1      1      1      4      1      3      1      5      1      3      1      1     13      1 
##    140    144    150    180    200    219    238    240    250    280    286    300    320    340    400 
##      1      1      3      2      5      1      1      4      1      2      1      3      3      1      3 
##    450    464    480    500    504    510    576    600    640    648    720    750    768    800    834 
##      1      1      4      5      1      1      1      4      1      1      3      1      1      4      1 
##    840    900    960   1000   1120   1152   1200   1240   1350   1440   1600   1728   1800   1920   2000 
##      1      1      3      4      1      2      2      1      1      2      3      1      1      4      3 
##   2160   2250   2280   2304   2400   2496   2500   2520   2800   2880   3000   3360   3600   3648   3650 
##      1      1      1      1      7      2      2      1      1      6      1      1      1      1      1 
##   3840   4200   4500   4704   4752   4800   5040   5200   5280   5600   5760   5780   5880   6000   6120 
##      1      2      1      2      1      7      1      1      1      2      3      1      1      1      1 
##   6240   6720   7200   7920   8000   8640   9125   9600  10800  11520  12000  13440  14400  15000  15840 
##      1      3      6      1      1      1      1      5      3      1      1      2      4      1      1 
##  16800  18000  19200  21000  25200  25923  28800  30240  32400  33600  36000  38400  63600  76800 192003 
##      1      4      1      1      1      1      2      1      1      1      3      1      1      1      1 
##   <NA> 
##   1795

## [1] "Frequency table after encoding"
## s8q15_1. Transport  Transportasyon
##             0             1            14            16            20            35            40 
##           265             1             1             1             4             1             3 
##            42            50            56            80            90            95           100 
##             1             5             1             3             1             1            13 
##           110           140           144           150           180           200           219 
##             1             1             1             3             2             5             1 
##           238           240           250           280           286           300           320 
##             1             4             1             2             1             3             3 
##           340           400           450           464           480           500           504 
##             1             3             1             1             4             5             1 
##           510           576           600           640           648           720           750 
##             1             1             4             1             1             3             1 
##           768           800           834           840           900           960          1000 
##             1             4             1             1             1             3             4 
##          1120          1152          1200          1240          1350          1440          1600 
##             1             2             2             1             1             2             3 
##          1728          1800          1920          2000          2160          2250          2280 
##             1             1             4             3             1             1             1 
##          2304          2400          2496          2500          2520          2800          2880 
##             1             7             2             2             1             1             6 
##          3000          3360          3600          3648          3650          3840          4200 
##             1             1             1             1             1             1             2 
##          4500          4704          4752          4800          5040          5200          5280 
##             1             2             1             7             1             1             1 
##          5600          5760          5780          5880          6000          6120          6240 
##             2             3             1             1             1             1             1 
##          6720          7200          7920          8000          8640          9125          9600 
##             3             6             1             1             1             1             5 
##         10800         11520         12000         13440         14400         15000         15840 
##             3             1             1             2             4             1             1 
##         16800         18000         19200         21000         25200         25923         28800 
##             1             4             1             1             1             1             2 
##         30240         32400         33600         36000         38400 51000 or more          <NA> 
##             1             1             1             3             1             3          1795

percentile_99.5 <- floor(quantile(na.exclude(mydata$s8q16_1)[na.exclude(mydata$s8q16_1)!=999999], probs = c(0.995)))
mydata <- top_recode (variable="s8q16_1", break_point=percentile_99.5, missing=999999)
## [1] "Frequency table before encoding"
## s8q16_1. Purchase of inputs, inventory, and products  Pagbili ng mga inilalagay, imbentar
##       0       1       7      42      50      60      70      80     100     144     150     200     240 
##     244       1       1       1       1       1       1       1       4       1       1       1       1 
##     300     331     350     360     400     440     444     450     500     528     600     680     700 
##       5       1       1       1       2       1       1       1      11       1       4       1       3 
##     720     750     800     838     920    1000    1200    1500    1600    1700    1920    2000    2400 
##       1       1       1       1       1      12       3       7       1       1       1      12       1 
##    2880    3000    3375    3840    4000    4800    5000    5760    6000    7000    7200    8000    9000 
##       1      12       1       1       5       2       6       1       4       3       3       5       2 
##    9600   10000   10800   12000   15000   16000   18000   19200   19800   20000   21000   21600   24000 
##       2      10       1       8       2       2       5       1       1       1       1       1       3 
##   30000   32160   33600   36000   38400   38880   39200   44000   45408   48000   50000   51600   54000 
##       2       1       2       3       1       1       1       1       1       7       1       1       1 
##   56000   57600   60000   64000   67200   70000   72000   75600   76800   80000   90000   93504   96000 
##       1       1       1       1       2       1       6       1       2       1       2       1       2 
##  100800  108000  112000  120000  134400  144000  180000  192000  235200  240000  288000  324000  336000 
##       1       1       1       3       1       6       1       1       1       1       2       1       1 
##  492750  504000  540000  576000  672000  690000  720000   9e+05 1080000    <NA> 
##       1       1       1       2       2       1       1       1       1    1800

## [1] "Frequency table after encoding"
## s8q16_1. Purchase of inputs, inventory, and products  Pagbili ng mga inilalagay, imbentar
##              0              1              7             42             50             60             70 
##            244              1              1              1              1              1              1 
##             80            100            144            150            200            240            300 
##              1              4              1              1              1              1              5 
##            331            350            360            400            440            444            450 
##              1              1              1              2              1              1              1 
##            500            528            600            680            700            720            750 
##             11              1              4              1              3              1              1 
##            800            838            920           1000           1200           1500           1600 
##              1              1              1             12              3              7              1 
##           1700           1920           2000           2400           2880           3000           3375 
##              1              1             12              1              1             12              1 
##           3840           4000           4800           5000           5760           6000           7000 
##              1              5              2              6              1              4              3 
##           7200           8000           9000           9600          10000          10800          12000 
##              3              5              2              2             10              1              8 
##          15000          16000          18000          19200          19800          20000          21000 
##              2              2              5              1              1              1              1 
##          21600          24000          30000          32160          33600          36000          38400 
##              1              3              2              1              2              3              1 
##          38880          39200          44000          45408          48000          50000          51600 
##              1              1              1              1              7              1              1 
##          54000          56000          57600          60000          64000          67200          70000 
##              1              1              1              1              1              2              1 
##          72000          75600          76800          80000          90000          93504          96000 
##              6              1              2              1              2              1              2 
##         100800         108000         112000         120000         134400         144000         180000 
##              1              1              1              3              1              6              1 
##         192000         235200         240000         288000         324000         336000         492750 
##              1              1              1              2              1              1              1 
##         504000         540000         576000         672000         690000 705749 or more           <NA> 
##              1              1              2              2              1              3           1800

percentile_99.5 <- floor(quantile(na.exclude(mydata$s8q17_1)[na.exclude(mydata$s8q17_1)!=999999], probs = c(0.995)))
mydata <- top_recode (variable="s8q17_1", break_point=percentile_99.5, missing=999999)
## [1] "Frequency table before encoding"
## s8q17_1. Other costs (exclude machinery, tools, durables already mentioned)  Iba pang gas
##      0      1     20     25    120    150    170    195    200    300    370    500    840    880   1000 
##    452      1      1      1      2      1      1      1      4      1      1      4      1      1      2 
##   1200   1500   1600   1800   2000   2400   2800   3240   5000   6048   7200   7300  10500  11132  12000 
##      1      1      1      5      1      1      1      1      1      1      2      1      1      1      1 
##  18000  21600  36000  45000  85000 108000   <NA> 
##      2      1      1      1      1      1   1795

## [1] "Frequency table after encoding"
## s8q17_1. Other costs (exclude machinery, tools, durables already mentioned)  Iba pang gas
##             0             1            20            25           120           150           170 
##           452             1             1             1             2             1             1 
##           195           200           300           370           500           840           880 
##             1             4             1             1             4             1             1 
##          1000          1200          1500          1600          1800          2000          2400 
##             2             1             1             1             5             1             1 
##          2800          3240          5000          6048          7200          7300         10500 
##             1             1             1             1             2             1             1 
##         11132         12000         18000         21600         36000 40500 or more          <NA> 
##             1             1             2             1             1             3          1795

percentile_99.5 <- floor(quantile(na.exclude(mydata$s8q20_1)[na.exclude(mydata$s8q20_1)!=999999], probs = c(0.995)))
mydata <- top_recode (variable="s8q20_1", break_point=percentile_99.5, missing=999999)
## [1] "Frequency table before encoding"
## s8q20_1. What was the total revenue received from this enterprise in the last 12 months? 
##       0       1     150     300     350     360     450     500     600     700     900    1000    1050 
##       8       1       1       5       1       1       1       6       1       1       3       2       1 
##    1200    1250    1440    1460    1500    1800    1900    2000    2100    2160    2244    2400    2450 
##       1       1       1       1       1       3       1       3       2       1       1       5       1 
##    2500    2800    3000    3100    3200    3360    3456    3500    3600    3840    4000    4200    4320 
##       1       2       9       1       1       1       1       1       5       1       4       1       1 
##    4500    4800    5000    5280    5400    5625    6000    6300    6500    7200    7500    7560    7680 
##       2      10       5       1       2       1       9       1       1       5       3       1       1 
##    7800    8000    8400    9000    9300    9600   10000   10080   10800   12000   12400   12600   12700 
##       1       1       3       3       1       2       3       2       1      14       1       3       2 
##   12960   14200   14400   14900   15000   15050   16000   16800   17280   18000   18480   19200   20000 
##       1       2       9       1       6       1       2       3       1      12       1       1       4 
##   20160   21600   22000   22400   22560   23040   23100   24000   24080   25000   25200   26400   26880 
##       1       1       1       2       1       1       1      15       1       1       3       1       2 
##   27000   28000   28800   29400   30000   31200   33600   34200   36000   36400   36500   38400   40000 
##       2       3       6       1       8       1       4       1      18       2       2       3       5 
##   42000   43200   44880   45000   45360   45600   48000   49000   49440   50000   50400   52500   53250 
##       4       4       1       2       1       1       4       1       1       1       2       1       1 
##   54000   54750   55200   57600   60000   61600   63700   67200   70000   72000   73200   74400   75600 
##       3       1       1       7       6       1       1       5       1      25       1       1       1 
##   76800   81150   84000   86700   89600   90000   91250   93600   95040   96000   97200   99000   1e+05 
##       2       1       3       1       1       2       1       1       1       3       1       1       1 
##  100800  104400  105000  108000  109500  115200  120000  130000  144000  145600  150000  153600  168000 
##       3       1       3      14       1       1       1       1       8       1       1       1       5 
##  180000  182500  196000  198000  210000  216000  218400  240000  252000  259200  268800  270000  288000 
##       6       1       1       1       1       4       2       1       2       1       1       1       4 
##   3e+05  326400  336000  346080  360000  369600  432000  450000  480000  504000  528000  720000  828000 
##       1       1       1       1       3       1       2       1       1       2       1       2       1 
##  840000 1152000 1440000 2340001    <NA> 
##       1       1       1       1    1817

## [1] "Frequency table after encoding"
## s8q20_1. What was the total revenue received from this enterprise in the last 12 months? 
##               0               1             150             300             350             360 
##               8               1               1               5               1               1 
##             450             500             600             700             900            1000 
##               1               6               1               1               3               2 
##            1050            1200            1250            1440            1460            1500 
##               1               1               1               1               1               1 
##            1800            1900            2000            2100            2160            2244 
##               3               1               3               2               1               1 
##            2400            2450            2500            2800            3000            3100 
##               5               1               1               2               9               1 
##            3200            3360            3456            3500            3600            3840 
##               1               1               1               1               5               1 
##            4000            4200            4320            4500            4800            5000 
##               4               1               1               2              10               5 
##            5280            5400            5625            6000            6300            6500 
##               1               2               1               9               1               1 
##            7200            7500            7560            7680            7800            8000 
##               5               3               1               1               1               1 
##            8400            9000            9300            9600           10000           10080 
##               3               3               1               2               3               2 
##           10800           12000           12400           12600           12700           12960 
##               1              14               1               3               2               1 
##           14200           14400           14900           15000           15050           16000 
##               2               9               1               6               1               2 
##           16800           17280           18000           18480           19200           20000 
##               3               1              12               1               1               4 
##           20160           21600           22000           22400           22560           23040 
##               1               1               1               2               1               1 
##           23100           24000           24080           25000           25200           26400 
##               1              15               1               1               3               1 
##           26880           27000           28000           28800           29400           30000 
##               2               2               3               6               1               8 
##           31200           33600           34200           36000           36400           36500 
##               1               4               1              18               2               2 
##           38400           40000           42000           43200           44880           45000 
##               3               5               4               4               1               2 
##           45360           45600           48000           49000           49440           50000 
##               1               1               4               1               1               1 
##           50400           52500           53250           54000           54750           55200 
##               2               1               1               3               1               1 
##           57600           60000           61600           63700           67200           70000 
##               7               6               1               1               5               1 
##           72000           73200           74400           75600           76800           81150 
##              25               1               1               1               2               1 
##           84000           86700           89600           90000           91250           93600 
##               3               1               1               2               1               1 
##           95040           96000           97200           99000           1e+05          100800 
##               1               3               1               1               1               3 
##          104400          105000          108000          109500          115200          120000 
##               1               3              14               1               1               1 
##          130000          144000          145600          150000          153600          168000 
##               1               8               1               1               1               5 
##          180000          182500          196000          198000          210000          216000 
##               6               1               1               1               1               4 
##          218400          240000          252000          259200          268800          270000 
##               2               1               2               1               1               1 
##          288000           3e+05          326400          336000          346080          360000 
##               4               1               1               1               1               3 
##          369600          432000          450000          480000          504000          528000 
##               1               2               1               1               2               1 
##          720000          828000          840000 1030320 or more            <NA> 
##               2               1               1               3            1817

percentile_99.5 <- floor(quantile(na.exclude(mydata$s8q21_1)[na.exclude(mydata$s8q21_1)!=999999], probs = c(0.995)))
mydata <- top_recode (variable="s8q21_1", break_point=percentile_99.5, missing=999999)
## [1] "Frequency table before encoding"
## s8q21_1. What are the sales of this enterprise in an average month?  Magkano ang benta ng
##      0     30     50     80    100    120    150    180    187    200    250    288    300    320    350 
##     10      1      1      1      2      2      5      1      1      4      1      1      9      1      2 
##    360    400    420    450    500    600    630    640    700    750    800    840    900   1000   1080 
##      2      6      1      3      7      6      1      1      3      1      4      1      1     10      1 
##   1200   1225   1250   1400   1500   1600   1680   1700   1750   1800   1880   1900   1920   1960   2000 
##     18      1      1      2     10      3      1      1      2      3      1      1      2      1     21 
##   2100   2200   2240   2400   2500   2800   3000   3080   3200   3300   3500   3600   3780   3800   3900 
##      1      2      1      6      6      6     24      1      5      1      1      6      1      1      1 
##   4000   4200   4400   4500   4600   4800   4850   5000   5250   5320   5600   6000   6100   6300   6400 
##      7      2      1      6      1      9      1      8      2      1      4     37      1      1      2 
##   6600   7000   7500   7583   7800   8000   8100   8250   8400   8760   9000   9100   9600   9800  10000 
##      1      1      9      1      1      4      1      1      6      1     26      1      1      1      5 
##  10143  11200  11400  12000  12500  12600  13440  13500  14000  14400  14440  15000  16500  16800  18000 
##      1      1      1      5      1      1      1      1      7      3      1     14      1      2      6 
##  18200  18333  19600  20000  21000  21300  21600  22400  22500  24000  25000  25200  27000  27200  28000 
##      1      1      1      4      3      1      1      3      2      3      1      1      1      1      1 
##  30000  30030  31800  33000  33600  36000  36400  37500  38000  39000  40000  42000  44352  45000  48000 
##      8      1      1      1      1      5      1      1      1      1      2      3      1      1      1 
##  54000  57600  60000  63000  66000  69000  76800  79500 120000 144000 150000 220800 285000 360000   <NA> 
##      1      1      2      1      1      1      1      1      3      1      1      1      1      1   1815

## [1] "Frequency table after encoding"
## s8q21_1. What are the sales of this enterprise in an average month?  Magkano ang benta ng
##              0             30             50             80            100            120            150 
##             10              1              1              1              2              2              5 
##            180            187            200            250            288            300            320 
##              1              1              4              1              1              9              1 
##            350            360            400            420            450            500            600 
##              2              2              6              1              3              7              6 
##            630            640            700            750            800            840            900 
##              1              1              3              1              4              1              1 
##           1000           1080           1200           1225           1250           1400           1500 
##             10              1             18              1              1              2             10 
##           1600           1680           1700           1750           1800           1880           1900 
##              3              1              1              2              3              1              1 
##           1920           1960           2000           2100           2200           2240           2400 
##              2              1             21              1              2              1              6 
##           2500           2800           3000           3080           3200           3300           3500 
##              6              6             24              1              5              1              1 
##           3600           3780           3800           3900           4000           4200           4400 
##              6              1              1              1              7              2              1 
##           4500           4600           4800           4850           5000           5250           5320 
##              6              1              9              1              8              2              1 
##           5600           6000           6100           6300           6400           6600           7000 
##              4             37              1              1              2              1              1 
##           7500           7583           7800           8000           8100           8250           8400 
##              9              1              1              4              1              1              6 
##           8760           9000           9100           9600           9800          10000          10143 
##              1             26              1              1              1              5              1 
##          11200          11400          12000          12500          12600          13440          13500 
##              1              1              5              1              1              1              1 
##          14000          14400          14440          15000          16500          16800          18000 
##              7              3              1             14              1              2              6 
##          18200          18333          19600          20000          21000          21300          21600 
##              1              1              1              4              3              1              1 
##          22400          22500          24000          25000          25200          27000          27200 
##              3              2              3              1              1              1              1 
##          28000          30000          30030          31800          33000          33600          36000 
##              1              8              1              1              1              1              5 
##          36400          37500          38000          39000          40000          42000          44352 
##              1              1              1              1              2              3              1 
##          45000          48000          54000          57600          60000          63000          66000 
##              1              1              1              1              2              1              1 
##          69000          76800          79500         120000         144000         150000 192480 or more 
##              1              1              1              3              1              1              3 
##           <NA> 
##           1815

percentile_99.5 <- floor(quantile(na.exclude(mydata$s8q23_1)[na.exclude(mydata$s8q23_1)!=999999], probs = c(0.995)))
mydata <- top_recode (variable="s8q23_1", break_point=percentile_99.5, missing=999999)
## [1] "Frequency table before encoding"
## s8q23_1. In the last twelve months, what was the amount your household earned as profit o
## -12960 -11000  -9600  -3000      0      1     30     40     50     80    100    150    190    200    250 
##      1      1      1      1     66      1      1      1      1      1      4      1      2      1      2 
##    300    344    350    360    380    400    450    480    500    550    600    700    720    800    900 
##      1      1      1      1      1      1      2      1      7      1      8      1      1      2      3 
##    920    960   1000   1200   1500   1550   1560   1650   1740   1800   1920   2000   2100   2244   2400 
##      1      1      3      3      8      1      1      1      1      3      1      4      2      1      5 
##   2500   2800   3000   3200   3450   3456   3600   3780   3800   3840   4000   4400   4500   4600   4800 
##      1      2     13      1      1      1      4      1      1      1      2      1      4      2      4 
##   5000   5550   6000   6300   6720   6930   6960   7000   7200   7500   7680   7700   7800   7920   8000 
##      5      1      2      1      1      1      1      3      3      2      2      1      1      1      4 
##   8080   8400   8650   8760   9000   9440   9600  10000  10080  10100  10400  10500  10560  10604  11496 
##      1      1      1      1      3      1      4     10      2      1      1      1      1      1      1 
##  12000  12400  12440  12540  12600  12960  13200  13860  14000  14130  14200  14250  14400  14700  14800 
##      9      1      1      1      1      1      1      1      1      1      2      1      2      1      1 
##  15000  15050  15680  16000  16060  16160  16320  16520  16600  16750  16800  18000  18480  19200  19800 
##      7      1      1      1      1      1      1      1      1      1      3      8      1      1      1 
##  20000  20400  20496  21000  21600  22080  22400  22560  22845  23000  23280  23316  23520  23950  24000 
##      3      1      1      2      3      1      1      1      1      1      1      1      1      1      4 
##  25200  26400  27000  27400  27450  28000  28800  28950  29568  30000  30800  30928  31200  31800  32400 
##      1      2      1      1      1      1      3      1      1      6      1      1      1      1      1 
##  33000  33420  33600  34000  35000  35040  35250  35600  36000  36400  36500  42000  43200  44352  45000 
##      1      1      2      1      2      1      1      1     10      1      2      2      2      1      1 
##  45600  48000  48864  48960  49000  49200  49428  49440  50000  50160  52500  53250  53880  54000  55000 
##      1      2      1      1      1      1      1      1      1      1      1      1      1      5      1 
##  55200  55866  57230  57600  57608  59600  60000  62755  63000  63600  67200  71600  71900  72000  74200 
##      1      1      1      3      1      1      4      1      1      2      3      1      1      9      1 
##  76800  79650  80000  86400  87200  90240  91000  93072  96000  97200 100800 102000 103000 106840 108000 
##      1      1      1      1      1      1      1      1      1      1      1      1      1      1      8 
## 109500 120000 127880 129504 143424 144000 149280 168000 168600 180000 182500 192000 237000 254400 259200 
##      1      1      1      1      1      2      1      1      1      2      1      1      1      1      1 
## 288000 360000 450000  2e+06   <NA> 
##      1      1      1      1   1821

## [1] "Frequency table after encoding"
## s8q23_1. In the last twelve months, what was the amount your household earned as profit o
##         -12960         -11000          -9600          -3000              0              1             30 
##              1              1              1              1             66              1              1 
##             40             50             80            100            150            190            200 
##              1              1              1              4              1              2              1 
##            250            300            344            350            360            380            400 
##              2              1              1              1              1              1              1 
##            450            480            500            550            600            700            720 
##              2              1              7              1              8              1              1 
##            800            900            920            960           1000           1200           1500 
##              2              3              1              1              3              3              8 
##           1550           1560           1650           1740           1800           1920           2000 
##              1              1              1              1              3              1              4 
##           2100           2244           2400           2500           2800           3000           3200 
##              2              1              5              1              2             13              1 
##           3450           3456           3600           3780           3800           3840           4000 
##              1              1              4              1              1              1              2 
##           4400           4500           4600           4800           5000           5550           6000 
##              1              4              2              4              5              1              2 
##           6300           6720           6930           6960           7000           7200           7500 
##              1              1              1              1              3              3              2 
##           7680           7700           7800           7920           8000           8080           8400 
##              2              1              1              1              4              1              1 
##           8650           8760           9000           9440           9600          10000          10080 
##              1              1              3              1              4             10              2 
##          10100          10400          10500          10560          10604          11496          12000 
##              1              1              1              1              1              1              9 
##          12400          12440          12540          12600          12960          13200          13860 
##              1              1              1              1              1              1              1 
##          14000          14130          14200          14250          14400          14700          14800 
##              1              1              2              1              2              1              1 
##          15000          15050          15680          16000          16060          16160          16320 
##              7              1              1              1              1              1              1 
##          16520          16600          16750          16800          18000          18480          19200 
##              1              1              1              3              8              1              1 
##          19800          20000          20400          20496          21000          21600          22080 
##              1              3              1              1              2              3              1 
##          22400          22560          22845          23000          23280          23316          23520 
##              1              1              1              1              1              1              1 
##          23950          24000          25200          26400          27000          27400          27450 
##              1              4              1              2              1              1              1 
##          28000          28800          28950          29568          30000          30800          30928 
##              1              3              1              1              6              1              1 
##          31200          31800          32400          33000          33420          33600          34000 
##              1              1              1              1              1              2              1 
##          35000          35040          35250          35600          36000          36400          36500 
##              2              1              1              1             10              1              2 
##          42000          43200          44352          45000          45600          48000          48864 
##              2              2              1              1              1              2              1 
##          48960          49000          49200          49428          49440          50000          50160 
##              1              1              1              1              1              1              1 
##          52500          53250          53880          54000          55000          55200          55866 
##              1              1              1              5              1              1              1 
##          57230          57600          57608          59600          60000          62755          63000 
##              1              3              1              1              4              1              1 
##          63600          67200          71600          71900          72000          74200          76800 
##              2              3              1              1              9              1              1 
##          79650          80000          86400          87200          90240          91000          93072 
##              1              1              1              1              1              1              1 
##          96000          97200         100800         102000         103000         106840         108000 
##              1              1              1              1              1              1              8 
##         109500         120000         127880         129504         143424         144000         149280 
##              1              1              1              1              1              2              1 
##         168000         168600         180000         182500         192000         237000         254400 
##              1              1              2              1              1              1              1 
##         259200         288000 333359 or more           <NA> 
##              1              1              3           1821

percentile_99.5 <- floor(quantile(na.exclude(mydata$s8q8_2)[na.exclude(mydata$s8q8_2)!=999999], probs = c(0.995)))
mydata <- top_recode (variable="s8q8_2", break_point=percentile_99.5, missing=999999)
## [1] "Frequency table before encoding"
## s8q8_2. How much was this start-up capital?  Magkano ang pangunang kapital na ito?
##     0   200   300   500  1000  1500  2000  2500  3000  3250  4500  5000  7000  8000 10000 15000 18000 20000 
##     1     2     3     5     5     3     1     1     5     1     1     7     1     1     4     3     1     2 
## 21500 28000 30000 40000  <NA> 
##     1     1     1     1  2245

## [1] "Frequency table after encoding"
## s8q8_2. How much was this start-up capital?  Magkano ang pangunang kapital na ito?
##             0           200           300           500          1000          1500          2000 
##             1             2             3             5             5             3             1 
##          2500          3000          3250          4500          5000          7000          8000 
##             1             5             1             1             7             1             1 
##         10000         15000         18000         20000         21500         28000         30000 
##             4             3             1             2             1             1             1 
## 37500 or more          <NA> 
##             1          2245

percentile_99.5 <- floor(quantile(na.exclude(mydata$s8q9_2)[na.exclude(mydata$s8q9_2)!=999999], probs = c(0.995)))
mydata <- top_recode (variable="s8q9_2", break_point=percentile_99.5, missing=999999)
## [1] "Frequency table before encoding"
## s8q9_2. In the last 12 months what was spent on machinery or durable goods (e.g., tools,
##     0   100   300   400   570   900  1000  1100  1500  2000  2800  6200 18000 24000 31200 45000  <NA> 
##    52     1     1     2     1     2     2     1     2     1     1     1     1     1     1     1  2225

## [1] "Frequency table after encoding"
## s8q9_2. In the last 12 months what was spent on machinery or durable goods (e.g., tools,
##             0           100           300           400           570           900          1000 
##            52             1             1             2             1             2             2 
##          1100          1500          2000          2800          6200         18000         24000 
##             1             2             1             1             1             1             1 
##         31200 40170 or more          <NA> 
##             1             1          2225

percentile_99.5 <- floor(quantile(na.exclude(mydata$s8q12_2)[na.exclude(mydata$s8q12_2)!=999999], probs = c(0.995)))
mydata <- top_recode (variable="s8q12_2", break_point=percentile_99.5, missing=999999)
## [1] "Frequency table before encoding"
## s8q12_2. Electricity  Kuryente
##     0    20   500   600  1100  2400 31800  <NA> 
##    65     1     1     1     1     1     1  2225

## [1] "Frequency table after encoding"
## s8q12_2. Electricity  Kuryente
##             0            20           500           600          1100          2400 21510 or more 
##            65             1             1             1             1             1             1 
##          <NA> 
##          2225

percentile_99.5 <- floor(quantile(na.exclude(mydata$s8q13_2)[na.exclude(mydata$s8q13_2)!=999999], probs = c(0.995)))
mydata <- top_recode (variable="s8q13_2", break_point=percentile_99.5, missing=999999)
## [1] "Frequency table before encoding"
## s8q13_2. Salaries/Wages  Pasahod/Suweldo 
##    0 1800 <NA> 
##   70    1 2225

## [1] "Frequency table after encoding"
## s8q13_2. Salaries/Wages  Pasahod/Suweldo 
##            0 1170 or more         <NA> 
##           70            1         2225

percentile_99.5 <- floor(quantile(na.exclude(mydata$s8q14_2)[na.exclude(mydata$s8q14_2)!=999999], probs = c(0.995)))
mydata <- top_recode (variable="s8q14_2", break_point=percentile_99.5, missing=999999)
## [1] "Frequency table before encoding"
## s8q14_2. Water  Tubig
##    0  320 7200 <NA> 
##   69    1    1 2225

## [1] "Frequency table after encoding"
## s8q14_2. Water  Tubig
##            0          320 4792 or more         <NA> 
##           69            1            1         2225

percentile_99.5 <- floor(quantile(na.exclude(mydata$s8q15_2)[na.exclude(mydata$s8q15_2)!=999999], probs = c(0.995)))
mydata <- top_recode (variable="s8q15_2", break_point=percentile_99.5, missing=999999)
## [1] "Frequency table before encoding"
## s8q15_2. Transport  Transportasyon
##     0    20    80   105   150   200   300   400   420   500   640  1152  1440  1500  2000  2400  2500  2880 
##    43     1     1     1     1     2     1     2     1     1     1     1     1     2     1     3     1     1 
##  4500  9000  9600 14400 19200  <NA> 
##     1     1     2     1     1  2225

## [1] "Frequency table after encoding"
## s8q15_2. Transport  Transportasyon
##             0            20            80           105           150           200           300 
##            43             1             1             1             1             2             1 
##           400           420           500           640          1152          1440          1500 
##             2             1             1             1             1             1             2 
##          2000          2400          2500          2880          4500          9000          9600 
##             1             3             1             1             1             1             2 
##         14400 17520 or more          <NA> 
##             1             1          2225

percentile_99.5 <- floor(quantile(na.exclude(mydata$s8q16_2)[na.exclude(mydata$s8q16_2)!=999999], probs = c(0.995)))
mydata <- top_recode (variable="s8q16_2", break_point=percentile_99.5, missing=999999)
## [1] "Frequency table before encoding"
## s8q16_2. Purchase of inputs, inventory, and products  Pagbili ng mga inilalagay, imbentar
##      0    150    300    500   1000   1100   1200   3200   4500   5000   8400  15000  18000  42000  48000 
##     47      1      1      3      1      1      1      1      1      2      1      1      1      1      1 
##  72000  78000  96000 234960   <NA> 
##      2      1      1      1   2227

## [1] "Frequency table after encoding"
## s8q16_2. Purchase of inputs, inventory, and products  Pagbili ng mga inilalagay, imbentar
##              0            150            300            500           1000           1100           1200 
##             47              1              1              3              1              1              1 
##           3200           4500           5000           8400          15000          18000          42000 
##              1              1              2              1              1              1              1 
##          48000          72000          78000          96000 187713 or more           <NA> 
##              1              2              1              1              1           2227

percentile_99.5 <- floor(quantile(na.exclude(mydata$s8q17_2)[na.exclude(mydata$s8q17_2)!=999999], probs = c(0.995)))
mydata <- top_recode (variable="s8q17_2", break_point=percentile_99.5, missing=999999)
## [1] "Frequency table before encoding"
## s8q17_2. Other costs (exclude machinery, tools, durables already mentioned)  Iba pang gas
##     0    40   600  1500  5475 12800 72000  <NA> 
##    65     1     1     1     1     1     1  2225

## [1] "Frequency table after encoding"
## s8q17_2. Other costs (exclude machinery, tools, durables already mentioned)  Iba pang gas
##             0            40           600          1500          5475         12800 51280 or more 
##            65             1             1             1             1             1             1 
##          <NA> 
##          2225

percentile_99.5 <- floor(quantile(na.exclude(mydata$s8q20_2)[na.exclude(mydata$s8q20_2)!=999999], probs = c(0.995)))
mydata <- top_recode (variable="s8q20_2", break_point=percentile_99.5, missing=999999)
## [1] "Frequency table before encoding"
## s8q20_2. What was the total revenue received from this enterprise in the last 12 months? 
##       0     300     350     500    1200    2700    3000    4000    4200    4800    5000    5200    6000 
##       3       1       1       1       1       1       1       1       1       1       1       1       2 
##    7000    8000   10000   12000   14400   15000   16800   18000   19200   20000   21000   21120   24000 
##       1       2       2       1       7       1       1       2       1       1       1       1       4 
##   28800   32360   36000   37500   38400   42000   43200   50400   54000   67200   72000   84000  108000 
##       1       1       5       1       1       1       1       1       3       1       3       1       1 
##  118286  144000  288000  360000 1080000    <NA> 
##       1       1       1       1       1    2229

## [1] "Frequency table after encoding"
## s8q20_2. What was the total revenue received from this enterprise in the last 12 months? 
##              0            300            350            500           1200           2700           3000 
##              3              1              1              1              1              1              1 
##           4000           4200           4800           5000           5200           6000           7000 
##              1              1              1              1              1              2              1 
##           8000          10000          12000          14400          15000          16800          18000 
##              2              2              1              7              1              1              2 
##          19200          20000          21000          21120          24000          28800          32360 
##              1              1              1              1              4              1              1 
##          36000          37500          38400          42000          43200          50400          54000 
##              5              1              1              1              1              1              3 
##          67200          72000          84000         108000         118286         144000         288000 
##              1              3              1              1              1              1              1 
##         360000 842400 or more           <NA> 
##              1              1           2229

percentile_99.5 <- floor(quantile(na.exclude(mydata$s8q21_2)[na.exclude(mydata$s8q21_2)!=999999], probs = c(0.995)))
mydata <- top_recode (variable="s8q21_2", break_point=percentile_99.5, missing=999999)
## [1] "Frequency table before encoding"
## s8q21_2. What are the sales of this enterprise in an average month?  Magkano ang benta ng
##      0    100    350    500    800   1000   1200   1250   1400   1500   1920   2000   2333   2600   2696 
##      3      1      2      2      1      3      8      1      1      4      1      4      1      1      1 
##   3000   3200   3280   3500   3600   4200   4500   5000   5400   5600   6000   8000   8400  12000  18000 
##      6      1      1      1      1      2      1      1      1      1      4      1      1      2      1 
##  19200  20000  24000  28800  30000  72000  90000 180000   <NA> 
##      1      2      1      1      2      1      1      1   2227

## [1] "Frequency table after encoding"
## s8q21_2. What are the sales of this enterprise in an average month?  Magkano ang benta ng
##              0            100            350            500            800           1000           1200 
##              3              1              2              2              1              3              8 
##           1250           1400           1500           1920           2000           2333           2600 
##              1              1              4              1              4              1              1 
##           2696           3000           3200           3280           3500           3600           4200 
##              1              6              1              1              1              1              2 
##           4500           5000           5400           5600           6000           8000           8400 
##              1              1              1              1              4              1              1 
##          12000          18000          19200          20000          24000          28800          30000 
##              2              1              1              2              1              1              2 
##          72000          90000 149399 or more           <NA> 
##              1              1              1           2227

percentile_99.5 <- floor(quantile(na.exclude(mydata$s8q23_2)[na.exclude(mydata$s8q23_2)!=999999], probs = c(0.995)))
mydata <- top_recode (variable="s8q23_2", break_point=percentile_99.5, missing=999999)
## [1] "Frequency table before encoding"
## s8q23_2. In the last twelve months, what was the amount your household earned as profit o
## -36000  -3000      0     50    300    480    500    850   1000   1200   1500   2333   2700   3280   4000 
##      1      1      7      1      1      1      2      1      1      2      1      1      1      1      3 
##   4200   4380   4800   5000   6000   8000   8400   9600   9700  10000  14000  14100  14400  15000  16500 
##      1      1      1      3      1      1      1      1      1      4      1      1      3      1      1 
##  18000  19200  20000  21120  23200  24000  32360  36000  37000  38400  53100  54000  60000  66700  69600 
##      1      1      1      1      1      2      1      3      1      1      1      1      1      1      1 
##  71430  72000 160800   <NA> 
##      1      1      1   2228

## [1] "Frequency table after encoding"
## s8q23_2. In the last twelve months, what was the amount your household earned as profit o
##         -36000          -3000              0             50            300            480            500 
##              1              1              7              1              1              1              2 
##            850           1000           1200           1500           2333           2700           3280 
##              1              1              2              1              1              1              1 
##           4000           4200           4380           4800           5000           6000           8000 
##              3              1              1              1              3              1              1 
##           8400           9600           9700          10000          14000          14100          14400 
##              1              1              1              4              1              1              3 
##          15000          16500          18000          19200          20000          21120          23200 
##              1              1              1              1              1              1              1 
##          24000          32360          36000          37000          38400          53100          54000 
##              2              1              3              1              1              1              1 
##          60000          66700          69600          71430          72000 131052 or more           <NA> 
##              1              1              1              1              1              1           2228

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("s8q1",
                  "s8q2_1",
                  "s8q2_2")
capture_tables (indirect_PII)

# Recode those with very specific values. 

break_ocup <- c(-999,-888,1,7,9,20,21,24,27,30,31,34,36,37,39,40,43,44)
labels_ocup <- c("No Response" = 1,
                "Other: Specify" = 2,
                "Other" = 3,
                "Elementary occupations" = 4,
                "Other" = 5,
                "Service and sales workers" = 6,
                "Service and sales workers" = 7,
                "Elementary occupations "= 8,
                "Craft and related trades workers "= 9,
                "Craft and related trades workers"= 10,
                "Elementary occupations"= 11,
                "Elementary occupations"=12,
                "Craft and related trades workers"=13,
                "Service and sales workers"=14,
                "Craft and related trades workers"=15,
                "Elementary occupations"=16,
                "Craft and related trades workers"=17,
                "Craft and related trades workers"=18)
mydata <- ordinal_recode (variable="s8q2_1", break_points=break_ocup, missing=999999, value_labels=labels_ocup)

## [1] "Frequency table before encoding"
## s8q2_1. What is the nature of this enterprise ?  Ano ang kalikasan ng negosyong ito?
##                                                                                      Earn a profit 
##                                                                                                  7 
##                                                                                        Make a loss 
##                                                                                                  9 
##                                                                                        Break even  
##                                                                                                  2 
##                                                       Street Work Including Scavenging And Begging 
##                                                                                                  2 
##                                                                         Commercial Sexual Activity 
##                                                                                                  1 
##                                                                      Hairdresser/Barber/Beautician 
##                                                                                                  6 
##                                                                            Consumer store operator 
##                                                                                                 71 
##                                                                Charcoal Makers And Related Workers 
##                                                                                                  8 
##                                                         Food Processing and Related Trades Workers 
##                                                                                                 23 
##                        Handicraft Workers In Wood, Textile, Leather, Chemicals And Related Workers 
##                                                                                                 49 
##                                                 Hotel Housekeepers And Restaurant Services Workers 
##                                                                                                  1 
##                                           Market Stall Vendors, Street Vendors And Related Workers 
##                                                                                                148 
## Metal Molders, Welders, Sheet-Metal Workers, Structural-Metal Preparers And Related Trades Workers 
##                                                                                                  3 
##                                                                              Motor Vehicle Drivers 
##                                                                                                  7 
##                                                        Printing Binding And Related Trades Workers 
##                                                                                                  1 
##                                     Shoe Cleaning And Other Street Services Elementary Occupations 
##                                                                                                  1 
##                                                        Textile, Garment And Related Trades Workers 
##                                                                                                  5 
##                                           Wood Treaters, Cabinet Makers And Related Trades Workers 
##                                                                                                  1 
##                                                                                               <NA> 
##                                                                                               1951 
##     recoded
##      [-999,-888) [-888,1) [1,7) [7,9) [9,20) [20,21) [21,24) [24,27) [27,30) [30,31) [31,34) [34,36) [36,37)
##   1            0        0     7     0      0       0       0       0       0       0       0       0       0
##   2            0        0     9     0      0       0       0       0       0       0       0       0       0
##   3            0        0     2     0      0       0       0       0       0       0       0       0       0
##   7            0        0     0     2      0       0       0       0       0       0       0       0       0
##   9            0        0     0     0      1       0       0       0       0       0       0       0       0
##   20           0        0     0     0      0       6       0       0       0       0       0       0       0
##   21           0        0     0     0      0       0      71       0       0       0       0       0       0
##   24           0        0     0     0      0       0       0       8       0       0       0       0       0
##   27           0        0     0     0      0       0       0       0      23       0       0       0       0
##   30           0        0     0     0      0       0       0       0       0      49       0       0       0
##   31           0        0     0     0      0       0       0       0       0       0       1       0       0
##   34           0        0     0     0      0       0       0       0       0       0       0     148       0
##   36           0        0     0     0      0       0       0       0       0       0       0       0       3
##   37           0        0     0     0      0       0       0       0       0       0       0       0       0
##   39           0        0     0     0      0       0       0       0       0       0       0       0       0
##   40           0        0     0     0      0       0       0       0       0       0       0       0       0
##   43           0        0     0     0      0       0       0       0       0       0       0       0       0
##   44           0        0     0     0      0       0       0       0       0       0       0       0       0
##     recoded
##      [37,39) [39,40) [40,43) [43,44) [44,1e+06)
##   1        0       0       0       0          0
##   2        0       0       0       0          0
##   3        0       0       0       0          0
##   7        0       0       0       0          0
##   9        0       0       0       0          0
##   20       0       0       0       0          0
##   21       0       0       0       0          0
##   24       0       0       0       0          0
##   27       0       0       0       0          0
##   30       0       0       0       0          0
##   31       0       0       0       0          0
##   34       0       0       0       0          0
##   36       0       0       0       0          0
##   37       7       0       0       0          0
##   39       0       1       0       0          0
##   40       0       0       1       0          0
##   43       0       0       0       5          0
##   44       0       0       0       0          1
## [1] "Frequency table after encoding"
## s8q2_1. What is the nature of this enterprise ?  Ano ang kalikasan ng negosyong ito?
##                             Other            Elementary occupations         Service and sales workers 
##                                19                               152                                84 
##           Elementary occupations  Craft and related trades workers   Craft and related trades workers 
##                                 8                                23                                59 
##                              <NA> 
##                              1951 
## [1] "Inspect value labels and relabel as necessary"
##                       No Response                    Other: Specify                             Other 
##                                 1                                 2                                 3 
##            Elementary occupations                             Other         Service and sales workers 
##                                 4                                 5                                 6 
##         Service and sales workers           Elementary occupations  Craft and related trades workers  
##                                 7                                 8                                 9 
##  Craft and related trades workers            Elementary occupations            Elementary occupations 
##                                10                                11                                12 
##  Craft and related trades workers         Service and sales workers  Craft and related trades workers 
##                                13                                14                                15 
##            Elementary occupations  Craft and related trades workers  Craft and related trades workers 
##                                16                                17                                18
mydata <- ordinal_recode (variable="s8q2_2", break_points=break_ocup, missing=999999, value_labels=labels_ocup)

## [1] "Frequency table before encoding"
## s8q2_2. What is the nature of this enterprise ?  Ano ang kalikasan ng negosyong ito?
##                                                                                      Earn a profit 
##                                                                                                  1 
##                                                                            Consumer store operator 
##                                                                                                  4 
##                                                         Food Processing and Related Trades Workers 
##                                                                                                  1 
##                        Handicraft Workers In Wood, Textile, Leather, Chemicals And Related Workers 
##                                                                                                  7 
##                                           Market Stall Vendors, Street Vendors And Related Workers 
##                                                                                                 20 
## Metal Molders, Welders, Sheet-Metal Workers, Structural-Metal Preparers And Related Trades Workers 
##                                                                                                  1 
##                                                                              Motor Vehicle Drivers 
##                                                                                                  5 
##                                                                                               <NA> 
##                                                                                               2257 
##     recoded
##      [-999,-888) [-888,1) [1,7) [7,9) [9,20) [20,21) [21,24) [24,27) [27,30) [30,31) [31,34) [34,36) [36,37)
##   1            0        0     1     0      0       0       0       0       0       0       0       0       0
##   21           0        0     0     0      0       0       4       0       0       0       0       0       0
##   27           0        0     0     0      0       0       0       0       1       0       0       0       0
##   30           0        0     0     0      0       0       0       0       0       7       0       0       0
##   34           0        0     0     0      0       0       0       0       0       0       0      20       0
##   36           0        0     0     0      0       0       0       0       0       0       0       0       1
##   37           0        0     0     0      0       0       0       0       0       0       0       0       0
##     recoded
##      [37,39) [39,40) [40,43) [43,44) [44,1e+06)
##   1        0       0       0       0          0
##   21       0       0       0       0          0
##   27       0       0       0       0          0
##   30       0       0       0       0          0
##   34       0       0       0       0          0
##   36       0       0       0       0          0
##   37       5       0       0       0          0
## [1] "Frequency table after encoding"
## s8q2_2. What is the nature of this enterprise ?  Ano ang kalikasan ng negosyong ito?
##                             Other            Elementary occupations         Service and sales workers 
##                                 1                                20                                 9 
## Craft and related trades workers   Craft and related trades workers                              <NA> 
##                                 1                                 8                              2257 
## [1] "Inspect value labels and relabel as necessary"
##                       No Response                    Other: Specify                             Other 
##                                 1                                 2                                 3 
##            Elementary occupations                             Other         Service and sales workers 
##                                 4                                 5                                 6 
##         Service and sales workers           Elementary occupations  Craft and related trades workers  
##                                 7                                 8                                 9 
##  Craft and related trades workers            Elementary occupations            Elementary occupations 
##                                10                                11                                12 
##  Craft and related trades workers         Service and sales workers  Craft and related trades workers 
##                                13                                14                                15 
##            Elementary occupations  Craft and related trades workers  Craft and related trades workers 
##                                16                                17                                18

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("s8q1whynoresponse",
               "s8q2_other_1",
               "s8q2whynoresponse_1",
               "s8q3whynoresponse_1",
               "s8q4whynoresponse_1",
               "s8q5whynoresponse_1",
               "s8q5awhynoresponse_1",
               "s8q6whynoresponse_1",
               "s8q7_other_1",
               "s8q7whynoresponse_1",
               "s8q8whynoresponse_1",
               "s8q9whynoresponse_1",
               "s8q10_other_1",
               "s8q10whynoresponse_1",
               "s8q11whynoresponse_1",
               "s8q12whynoresponse_1",
               "s8q13whynoresponse_1",
               "s8q14whynoresponse_1",
               "s8q15whynoresponse_1",
               "s8q16whynoresponse_1",
               "s8q17whynoresponse_1",
               "s8q18_1",
               "s8q19_other_1",
               "s8q19whynoresponse_1",
               "s8q20whynoresponse_1",
               "s8q21whynoresponse_1",
               "s8q22whynoresponse_1",
               "s8q23whynoresponse_1",
               "s8q2_other_2",
               "s8q2whynoresponse_2",
               "s8q3whynoresponse_2",
               "s8q4whynoresponse_2",
               "s8q5whynoresponse_2",
               "s8q5awhynoresponse_2",
               "s8q6whynoresponse_2",
               "s8q7_other_2",
               "s8q7whynoresponse_2",
               "s8q8whynoresponse_2",
               "s8q9whynoresponse_2",
               "s8q10_other_2",
               "s8q10whynoresponse_2",
               "s8q11whynoresponse_2",
               "s8q12whynoresponse_2",
               "s8q13whynoresponse_2",
               "s8q14whynoresponse_2",
               "s8q15whynoresponse_2",
               "s8q16whynoresponse_2",
               "s8q17whynoresponse_2",
               "s8q18_2",
               "s8q19_other_2",
               "s8q19whynoresponse_2",
               "s8q20whynoresponse_2",
               "s8q21whynoresponse_2",
               "s8q22whynoresponse_2",
               "s8q23whynoresponse_2",
               "s8q2_other_3",
               "s8q2whynoresponse_3",
               "s8q3whynoresponse_3",
               "s8q4whynoresponse_3",
               "s8q5whynoresponse_3",
               "s8q5awhynoresponse_3",
               "s8q6whynoresponse_3",
               "s8q7_other_3",
               "s8q7whynoresponse_3",
               "s8q8whynoresponse_3",
               "s8q9whynoresponse_3",
               "s8q10_other_3",
               "s8q10whynoresponse_3",
               "s8q11whynoresponse_3",
               "s8q12whynoresponse_3",
               "s8q13whynoresponse_3",
               "s8q14whynoresponse_3",
               "s8q15whynoresponse_3",
               "s8q16whynoresponse_3",
               "s8q17whynoresponse_3",
               "s8q18_3",
               "s8q19_other_3",
               "s8q19whynoresponse_3",
               "s8q20whynoresponse_3",
               "s8q21whynoresponse_3",
               "s8q22whynoresponse_3",
               "s8q23whynoresponse_3")

report_open (list_open_ends = open_ends)


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

mydata$s8q2_other_1[215] <- "Managers"
mydata$s8q2_other_1[281] <- "Managers"
mydata$s8q2_other_1[322] <- "Managers"
mydata$s8q2_other_1[460] <- "Managers"
mydata$s8q2_other_1[480] <- "Managers"
mydata$s8q2_other_1[492] <- "Managers"
mydata$s8q2_other_1[497] <- "Managers"
mydata$s8q2_other_1[520] <- "Managers"
mydata$s8q2_other_1[541] <- "Managers"
mydata$s8q2_other_1[546] <- "Managers"
mydata$s8q2_other_1[553] <- "Managers"
mydata$s8q2_other_1[557] <- "Managers"
mydata$s8q2_other_1[573] <- "Managers"
mydata$s8q2_other_1[593] <- "Managers"
mydata$s8q2_other_1[627] <- "Managers"
mydata$s8q2_other_1[704] <- "Managers"
mydata$s8q2_other_1[735] <- "Managers"
mydata$s8q2_other_1[859] <- "Managers"
mydata$s8q2_other_1[869] <- "Managers"
mydata$s8q2_other_1[937] <- "Managers"
mydata$s8q2_other_1[944] <- "Managers"
mydata$s8q2_other_1[966] <- "Managers"
mydata$s8q2_other_1[1013] <- "Managers"
mydata$s8q2_other_1[1019] <- "Managers"
mydata$s8q2_other_1[1021] <- "Managers"
mydata$s8q2_other_1[1022] <- "Managers"
mydata$s8q2_other_1[1152] <- "Managers"
mydata$s8q2_other_1[1171] <- "Managers"
mydata$s8q2_other_1[1228] <- "Managers"
mydata$s8q2_other_1[1408] <- "Managers"
mydata$s8q2_other_1[1414] <- "Managers"
mydata$s8q2_other_1[1553] <- "Managers"
mydata$s8q2_other_1[1638] <- "Managers"
mydata$s8q2_other_1[1649] <- "Managers"
mydata$s8q2_other_1[1888] <- "Managers"
mydata$s8q2_other_1[1890] <- "Managers"
mydata$s8q2_other_1[1926] <- "Managers"
mydata$s8q2_other_1[1928] <- "Managers"
mydata$s8q2_other_1[1935] <- "Managers"
mydata$s8q2_other_1[1958] <- "Managers"
mydata$s8q2_other_1[2015] <- "Managers"
mydata$s8q2_other_1[2028] <- "Managers"
mydata$s8q2_other_1[2066] <- "Managers"
mydata$s8q2_other_1[2145] <- "Managers"
mydata$s8q2_other_1[2171] <- "Managers"
mydata$s8q2_other_1[2177] <- "Managers"
mydata$s8q2_other_1[2226] <- "Managers"
mydata$s8q2_other_1[2265] <- "Managers"
mydata$s8q2_other_1[2279] <- "Managers"
mydata$s8q2_other_1[2281] <- "Managers"
mydata$s8q2_other_1[577] <- "Managers"
mydata$s8q2_other_1[623] <- "Managers"
mydata$s8q2_other_1[1696] <- "Managers"
mydata$s8q2_other_1[2031] <- "Managers"
mydata$s8q2_other_1[2278] <- "Managers"


mydata$s8q2_other_1[800] <- "Craft and related trades workers"
mydata$s8q2_other_1[1150] <- "Craft and related trades workers"
mydata$s8q2_other_1[1293] <- "Craft and related trades workers"
mydata$s8q2_other_1[1296] <- "Craft and related trades workers"
mydata$s8q2_other_1[1302] <- "Craft and related trades workers"
mydata$s8q2_other_1[1543] <- "Craft and related trades workers"
mydata$s8q2_other_1[1565] <- "Craft and related trades workers"
mydata$s8q2_other_1[1599] <- "Craft and related trades workers"
mydata$s8q2_other_1[1604] <- "Craft and related trades workers"
mydata$s8q2_other_1[1606] <- "Craft and related trades workers"
mydata$s8q2_other_1[1610] <- "Craft and related trades workers"
mydata$s8q2_other_1[1697] <- "Craft and related trades workers"
mydata$s8q2_other_1[1699] <- "Craft and related trades workers"
mydata$s8q2_other_1[1707] <- "Craft and related trades workers"
mydata$s8q2_other_1[1711] <- "Craft and related trades workers"
mydata$s8q2_other_1[1770] <- "Craft and related trades workers"
mydata$s8q2_other_1[1783] <- "Craft and related trades workers"
mydata$s8q2_other_1[1785] <- "Craft and related trades workers"
mydata$s8q2_other_1[1789] <- "Craft and related trades workers"
mydata$s8q2_other_1[1819] <- "Craft and related trades workers"
mydata$s8q2_other_1[1166] <- "Craft and related trades workers"
mydata$s8q2_other_1[1862] <- "Craft and related trades workers"
mydata$s8q2_other_1[2201] <- "Craft and related trades workers"


mydata$s8q2_other_1[176] <- "Service and sales workers"
mydata$s8q2_other_1[192] <- "Service and sales workers"
mydata$s8q2_other_1[519] <- "Service and sales workers"
mydata$s8q2_other_1[526] <- "Service and sales workers"
mydata$s8q2_other_1[604] <- "Service and sales workers"
mydata$s8q2_other_1[645] <- "Service and sales workers"
mydata$s8q2_other_1[751] <- "Service and sales workers"
mydata$s8q2_other_1[752] <- "Service and sales workers"
mydata$s8q2_other_1[925] <- "Service and sales workers"
mydata$s8q2_other_1[928] <- "Service and sales workers"
mydata$s8q2_other_1[929] <- "Service and sales workers"
mydata$s8q2_other_1[1125] <- "Service and sales workers"
mydata$s8q2_other_1[1127] <- "Service and sales workers"
mydata$s8q2_other_1[1157] <- "Service and sales workers"
mydata$s8q2_other_1[1199] <- "Service and sales workers"
mydata$s8q2_other_1[1200] <- "Service and sales workers"
mydata$s8q2_other_1[1206] <- "Service and sales workers"
mydata$s8q2_other_1[1278] <- "Service and sales workers"
mydata$s8q2_other_1[1309] <- "Service and sales workers"
mydata$s8q2_other_1[1315] <- "Service and sales workers"
mydata$s8q2_other_1[1347] <- "Service and sales workers"
mydata$s8q2_other_1[1356] <- "Service and sales workers"
mydata$s8q2_other_1[1455] <- "Service and sales workers"
mydata$s8q2_other_1[1541] <- "Service and sales workers"
mydata$s8q2_other_1[1551] <- "Service and sales workers"
mydata$s8q2_other_1[1571] <- "Service and sales workers"
mydata$s8q2_other_1[1583] <- "Service and sales workers"
mydata$s8q2_other_1[1655] <- "Service and sales workers"
mydata$s8q2_other_1[1661] <- "Service and sales workers"
mydata$s8q2_other_1[1708] <- "Service and sales workers"
mydata$s8q2_other_1[1722] <- "Service and sales workers"
mydata$s8q2_other_1[1733] <- "Service and sales workers"
mydata$s8q2_other_1[1804] <- "Service and sales workers"
mydata$s8q2_other_1[1807] <- "Service and sales workers"
mydata$s8q2_other_1[1875] <- "Service and sales workers"
mydata$s8q2_other_1[1880] <- "Service and sales workers"
mydata$s8q2_other_1[1920] <- "Service and sales workers"
mydata$s8q2_other_1[1925] <- "Service and sales workers"
mydata$s8q2_other_1[1931] <- "Service and sales workers"
mydata$s8q2_other_1[2022] <- "Service and sales workers"
mydata$s8q2_other_1[2024] <- "Service and sales workers"
mydata$s8q2_other_1[2058] <- "Service and sales workers"
mydata$s8q2_other_1[2062] <- "Service and sales workers"
mydata$s8q2_other_1[2143] <- "Service and sales workers"
mydata$s8q2_other_1[2167] <- "Service and sales workers"
mydata$s8q2_other_1[2190] <- "Service and sales workers"
mydata$s8q2_other_1[2229] <- "Service and sales workers"
mydata$s8q2_other_1[2238] <- "Service and sales workers"
mydata$s8q2_other_1[2244] <- "Service and sales workers"
mydata$s8q2_other_1[2270] <- "Service and sales workers"
mydata$s8q2_other_1[1527] <- "Service and sales workers"
mydata$s8q2_other_1[1530] <- "Service and sales workers"
mydata$s8q2_other_1[1539] <- "Service and sales workers"
mydata$s8q2_other_1[1540] <- "Service and sales workers"
mydata$s8q2_other_1[1551] <- "Service and sales workers"
mydata$s8q2_other_1[1566] <- "Service and sales workers"
mydata$s8q2_other_1[1587] <- "Service and sales workers"
mydata$s8q2_other_1[1588] <- "Service and sales workers"
mydata$s8q2_other_1[1595] <- "Service and sales workers"
mydata$s8q2_other_1[1626] <- "Service and sales workers"
mydata$s8q2_other_1[1629] <- "Service and sales workers"
mydata$s8q2_other_1[1631] <- "Service and sales workers"
mydata$s8q2_other_1[1846] <- "Service and sales workers"
mydata$s8q2_other_1[1885] <- "Service and sales workers"
mydata$s8q2_other_1[1917] <- "Service and sales workers"
mydata$s8q2_other_1[2063] <- "Service and sales workers"
mydata$s8q2_other_1[2072] <- "Service and sales workers"
mydata$s8q2_other_1[2105] <- "Service and sales workers"
mydata$s8q2_other_1[2166] <- "Service and sales workers"
mydata$s8q2_other_1[2182] <- "Service and sales workers"

mydata$s8q2_other_1[1765] <- "Plant and machine operators and assemblers"
mydata$s8q2_other_1[1780] <- "Plant and machine operators and assemblers"
mydata$s8q2_other_1[1946] <- "Plant and machine operators and assemblers"
mydata$s8q2_other_1[2006] <- "Plant and machine operators and assemblers"

mydata$s8q2_other_1[1188] <- "Skilled agricultural, forestry and fishery workers"
mydata$s8q2_other_1[1704] <- "Skilled agricultural, forestry and fishery workers"


mydata$s8q2_other_1[1188] <- "Elementary occupations"
mydata$s8q2_other_1[1704] <- "Elementary occupations"

mydata$s8q2whynoresponse_1[1536] <- "Service and sales workers"
mydata$s8q2whynoresponse_1[1544] <- "Service and sales workers"


mydata$s8q2_other_2[101] <- "Service and sales workers"
mydata$s8q2_other_2[520] <- "Service and sales workers"
mydata$s8q2_other_2[1166] <- "Service and sales workers"
mydata$s8q2_other_2[1471] <- "Service and sales workers"
mydata$s8q2_other_2[1543] <- "Service and sales workers"
mydata$s8q2_other_2[1560] <- "Service and sales workers"
mydata$s8q2_other_2[1567] <- "Service and sales workers"
mydata$s8q2_other_2[1592] <- "Service and sales workers"
mydata$s8q2_other_2[1617] <- "Service and sales workers"
mydata$s8q2_other_2[1637] <- "Service and sales workers"
mydata$s8q2_other_2[1638] <- "Service and sales workers"
mydata$s8q2_other_2[1921] <- "Service and sales workers"
mydata$s8q2_other_2[2012] <- "Service and sales workers"
mydata$s8q2_other_2[2145] <- "Service and sales workers"
mydata$s8q2_other_2[2161] <- "Service and sales workers"
mydata$s8q2_other_2[2167] <- "Service and sales workers"
mydata$s8q2_other_2[2174] <- "Service and sales workers"
mydata$s8q2_other_2[2165] <- "Service and sales workers"
mydata$s8q2_other_2[2087] <- "Service and sales workers"


mydata$s8q2_other_2[577] <- "Managers"
mydata$s8q2_other_2[1158] <- "Managers"
mydata$s8q2_other_2[1324] <- "Managers"
mydata$s8q2_other_2[2171] <- "Managers"

mydata$s8q2_other_2[1231] <- "Craft and related trades workers"
mydata$s8q2_other_2[1295] <- "Craft and related trades workers"
mydata$s8q2_other_2[1336] <- "Craft and related trades workers"

mydata$s8q2_other_2[1391] <- "Elementary occupations"
mydata$s8q2_other_2[1866] <- "Elementary occupations"

mydata$s8q2_other_2[1931] <- "Skilled agricultural, forestry and fishery workers"

mydata$s8q2_other_2[1722] <- "Plant and machine operators and assemblers"

mydata$s8q7_other_1[541] <- "[Wholesale and retail trade]"
mydata$s8q7_other_1[798] <- "Income of spouse from [Wholesale and retail trade]"
mydata$s8q7_other_1[929] <- "Earnings from [Wholesale and retail trade]"
mydata$s8q7_other_1[1048] <- "Earnings from [Wholesale and retail trade]"
mydata$s8q7_other_1[1195] <- "From own child [name redacted]"
mydata$s8q7_other_1[1233] <- "[Service and sales workers]"
mydata$s8q7_other_1[1586] <- "[Technicians and associate professionals]"
mydata$s8q7_other_1[1862] <- "[language]"
mydata$s8q7_other_1[2036] <- "[repair of motor vehicles and motorcycles]"

mydata$s8q10_other_1[541] <- "Income from [Agriculture, forestry and fishing]"
mydata$s8q10_other_1[929] <- "Sales from the [Transportation and storage]"
mydata$s8q10_other_1[1195] <- "[Wholesale and retail trade]"
mydata$s8q10_other_1[1233] <- "Loans from [Service and sales workers]"

mydata$s8q18_1[541] <- "Charcoal [amount redacted] per month"
mydata$s8q18_1[929] <- "[amount redacted]"
mydata$s8q18_1[1195] <- "[amount redacted]"

mydata$s8q19_other_1[432] <- "Everyday sales from [Wholesale and retail trade]"
mydata$s8q19_other_1[541] <- "Sales from the [Wholesale and retail trade]"
mydata$s8q19_other_1[627] <- "Loan from friend, personal and [Wholesale and retail trade]"
mydata$s8q19_other_1[859] <- "[Wholesale and retail trade] sales"
mydata$s8q19_other_1[926] <- "Daily sales from [Wholesale and retail trade]."

mydata$s8q19whynoresponse_1[1372] <- "[language]"

mydata$s8q21whynoresponse_1[257] <- "Operating for [number redacted] days only, [amount redacted]"
mydata$s8q21whynoresponse_1[1389] <- "[amount redacted]"

mydata$s8q22whynoresponse_1[322] <- "The store started for 1 week only"

mydata$s8q23whynoresponse_1[865] <- "Breakeven only, but sometimes she can save [amount redacted] but not always"

mydata$s8q2whynoresponse_2[859] <- "[Manager]"
mydata$s8q2whynoresponse_2[1541] <- "[Transportation and storage]"

mydata$s8q7_other_2[1560] <- "[language]"
mydata$s8q10_other_2[1543] <- "Workmate - [Service and sales worker]"

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)