rm(list=ls(all=t))

Setup filenames

filename <- "ECE 2016 (B1)" # !!!Update filename

if (!require("pacman")) install.packages("pacman")
pacman::p_load(rio)
rio::convert(paste0(filename, ".xlsx"), paste0(filename, ".dta"))

functions_vers <-  "functions_1.7.R" # !!!Update helper functions file

Setup data, functions and create dictionary for dataset review

source (functions_vers)

# Label vars

var_label(mydata$cod_mod7) <-"Codigo modular de la IE (Muestra DFM)"
var_label(mydata$anexo) <-"Anexo de la IE (Muestra DFM)"
var_label(mydata$grado) <-"Grado de la IE (Muestra DFM)"
var_label(mydata$dni) <-"Dni del estudiante (Muestra DFM)"
var_label(mydata$nombres) <-"Nombres del estudiante (Muestra DFM)"
var_label(mydata$apellido_paterno) <-"Apellido paterno del estudiante (Muestra DFM)"
var_label(mydata$apellido_materno) <-"Apellido materno del estudiante (Muestra DFM)"
var_label(mydata$ID_seccion_ece16) <-"ID de la Seccion(Aula) donde el estudiante fue evaluado en la ECE 2016"
var_label(mydata$cor_est_ece16) <-"Correlativo del estudiante cuando fue evaluado en la ECE 2016"
var_label(mydata$paterno_ece16) <-"Apellido paterno del estudiante en la ECE 2016"
var_label(mydata$materno_ece16) <-"Apellido materno del estudiante en la ECE 2016"
var_label(mydata$nombre1_ece16) <-"Primer nombre del estudiante en la ECE 2016"
var_label(mydata$nombre2_ece16) <-"Segundo nombre del estudiante en la ECE 2016"
var_label(mydata$M500_L_ece16) <-"Medida Promedio en Comprension Lectora del estudiante en la ECE2016"
var_label(mydata$M500_M_ece16) <-"Medida Promedio en Matematica del estudiante en la ECE2016"
var_label(mydata$M500_H_ece16) <-"Medida Promedio en Historia, Geografia y Economia del estudiante en la ECE2016"
var_label(mydata$grupo_L_ece16) <-"Nivel de desempeno en Comprension Lectora del estudiante en la ECE2016"
var_label(mydata$grupo_M_ece16) <-"Nivel de desempeno en Matematica del estudiante en la ECE2016"
var_label(mydata$grupo_HGE_ece16) <-"Nivel de desempeno en Historia, Geografia y Economia del estudiante en la ECE2016"

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

# !!!Include any Direct PII variables
dropvars <- c("dni",
              "nombres",
              "apellido_paterno",
              "apellido_materno",
              "paterno_ece16",
              "materno_ece16",
              "nombre1_ece16",
              "nombre2_ece16") 
mydata <- mydata[!names(mydata) %in% dropvars]

Direct PII-team: Encode field team names

# !!!No Direct PII - team

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

# !!!Include relevant variables, but check their population size first to confirm they are <100,000

locvars <- c("cod_mod7") 
mydata <- encode_location (variables= locvars, missing=999999)
## [1] "Frequency table before encoding"
## cod_mod7. Codigo modular de la IE (Muestra DFM)
## 0207449 0207472 0207480 0207506 0209270 0209304 0209387 0209510 0209528 0209536 0209908 0209916 0209924 0209940 
##     226      88      42      68     155      63      86     218      40     207     169      27     228     139 
## 0209965 0233056 0233064 0233130 0233270 0233288 0236109 0236117 0236174 0236182 0236224 0236232 0236349 0236364 
##     266     373     159     166     105      73     263     254     244      68     202      46     188      42 
## 0236414 0236778 0236786 0238667 0238675 0238808 0238840 0239798 0239814 0239822 0240184 0240259 0240267 0242271 
##     101     116     109     123     266      43     381      54     179     103     238     193     219     207 
## 0242289 0245647 0245654 0245662 0245670 0245688 0245696 0245704 0262188 0262196 0273516 0273524 0275438 0275479 
##     232     154     162     107     179     224     143      61     184     111     206     181     415      83 
## 0275487 0275545 0275552 0275719 0290569 0290585 0290601 0290619 0290874 0290890 0302711 0302885 0302893 0302943 
##      59      71     351     224     359     190     211      65     183     149      45     367     134     305 
## 0302950 0302968 0304444 0305656 0309187 0309229 0309260 0309302 0309310 0309336 0309377 0309385 0309401 0309435 
##     369     118     383      76     223     277     177      64     107      67     119     114      42      83 
## 0309443 0309468 0309492 0309500 0309526 0309633 0309641 0309682 0309773 0309781 0309799 0309807 0309823 0309856 
##      46     122     113      52      35      59     122      19     244     193     214      96     112      29 
## 0309898 0310185 0310219 0310441 0310516 0322479 0323345 0324772 0325449 0325456 0325464 0325472 0325480 0325498 
##      48      25      83      34     156      67      33      75      54     153     205     313     185     185 
## 0325506 0325548 0325555 0325563 0325589 0325597 0325605 0325613 0325621 0325639 0325647 0325654 0325662 0325670 
##      25     156      98      36     137     164     145     258     112      85     258      34     245     107 
## 0325696 0325704 0325712 0327379 0327486 0327650 0329326 0329573 0329755 0329805 0329813 0330464 0334649 0334656 
##      90     217     116     117      77     126     157     187     156      73      67      31      88     188 
## 0334664 0334672 0334680 0334706 0334714 0334722 0334730 0334748 0334771 0336495 0336511 0336537 0336545 0336578 
##     215      15      12     290      11     219      78     103      16     278      22      94     238      46 
## 0336586 0336594 0336602 0336610 0336628 0336636 0336891 0337436 0337568 0337592 0337717 0337733 0337741 0337766 
##     174      66      19     300     267      15     178     133     233      13      19      57      13      49 
## 0340224 0340281 0340299 0340315 0340323 0340331 0340349 0340356 0340364 0340372 0340380 0340398 0340414 0340422 
##     175      51     125     117      82      27     294      36      39      70      98      43     218     124 
## 0340430 0340448 0340463 0343566 0355875 0355883 0355891 0355990 0356071 0356089 0356188 0356329 0356634 0356758 
##     161     131      10     111      66      34      11     399     142     182     226     168      46     155 
## 0356766 0372508 0372540 0372565 0372581 0372599 0372680 0372698 0372946 0373761 0373787 0375758 0390591 0390609 
##      48     475     295     208     280     464     427      71      56     509     312      92     458     356 
## 0390617 0390690 0390708 0391060 0391078 0394288 0394353 0394445 0394775 0394825 0395061 0395079 0395087 0395103 
##      80     162     280     178     135     110      96      97     389      63     239     104     102     129 
## 0395111 0395152 0395228 0395236 0395251 0395269 0411736 0421248 0421396 0424507 0424523 0424564 0424572 0424580 
##      41     144     370     468     188     317     196     232      63     471     198      55     115     250 
## 0424606 0424770 0427427 0427690 0427708 0427716 0427955 0427971 0432773 0436642 0437210 0437228 0437236 0437244 
##     226      56      69     216     145      41      12      27     130      66      48     304     138     219 
## 0437251 0437269 0437277 0437285 0437293 0437319 0437327 0437335 0437343 0437350 0437368 0437400 0437509 0437517 
##     258     366     161     183      68      56      24      46     251     117      23     102     100     174 
## 0437525 0437533 0437541 0437707 0437715 0437723 0437731 0437749 0437772 0449819 0449827 0449868 0452565 0452573 
##      88     106     127      91      59     108     135     259      37      72      59     217     430     430 
## 0452599 0452623 0452631 0452649 0452656 0452722 0452730 0452748 0452763 0452771 0452847 0452854 0452862 0453597 
##     284     286      81     269     173      32     120      60      81     147     185     249      29     318 
## 0453605 0453647 0466383 0466722 0466730 0469205 0469700 0472209 0472472 0478479 0481184 0481242 0481820 0481853 
##     219     191      27      67      62     162      74      33      28     184      81      71     145      65 
## 0481903 0482042 0488619 0488635 0489096 0492504 0492769 0492876 0493544 0493635 0493742 0493841 0494070 0495150 
##      46      78     107      30      66     136      94      92     101     200     109      56      61      30 
## 0495259 0495424 0495762 0495812 0496166 0496265 0497081 0498782 0498824 0498881 0498998 0499228 0499699 0500124 
##      88     127     128     115      59      56       5      41     167      24      99      60     236      63 
## 0500330 0500348 0500611 0501411 0501502 0501601 0501676 0501700 0501809 0501908 0502047 0502104 0502336 0502435 
##      46      49     128      76     176     128      27      97      38      16      82      36     146     195 
## 0502484 0502633 0504993 0505149 0507806 0508168 0508267 0510396 0515668 0516963 0517698 0518241 0519645 0520064 
##      71      93     292     171      16      21     104       9      56      74      24     119     151     152 
## 0520486 0521179 0522318 0522862 0523423 0523431 0523472 0523621 0524637 0525725 0533752 0535195 0535666 0535724 
##     286     100      74     136     109      16     160     261      76      71      58      67      28     122 
## 0535823 0535930 0536029 0536128 0536151 0536326 0536714 0537761 0542357 0544957 0545053 0545251 0545459 0545509 
##     149      91     105      91     189     108      75     120      49     161     149      14     171      85 
## 0546002 0546986 0547083 0547463 0547877 0547976 0550749 0552612 0553412 0553420 0553511 0553529 0554824 0555847 
##      93     182     110      40      67     163      12      82      69      26      30      91     169      13 
## 0555862 0555946 0556266 0556332 0556340 0556449 0556472 0556571 0564252 0565119 0565143 0565176 0565200 0565234 
##      20     104      46      23      54      88      24      56      63      18      77      95     145     139 
## 0565267 0566141 0566158 0566166 0566414 0566422 0566430 0566448 0566455 0566463 0566471 0566489 0566927 0566950 
##      82     152      99      37      75     107      57      52      92      98     131      39      15       7 
## 0567743 0567750 0568592 0568618 0568915 0569053 0569566 0569988 0570010 0570044 0570648 0571620 0572032 0572768 
##      15      67      32     143      58     160      42      47      87      62       6      26     160      46 
## 0573352 0576363 0576389 0576439 0576736 0577346 0577379 0577387 0577478 0577486 0577783 0577817 0577825 0577833 
##      10      37      19      39      42     229      27     182     106     235      56      70     145      68 
## 0577841 0577858 0577866 0577874 0577882 0577890 0577908 0577916 0578260 0578278 0578286 0578294 0578336 0578351 
##     101      66     152      76      29     115      41      60      27      27     137      48      23      20 
## 0578393 0578401 0578435 0578443 0578450 0578468 0578492 0578500 0578518 0578526 0578534 0578542 0578559 0578773 
##      19      13      23      48     121      77      23     150     104      55     188      89      58      81 
## 0578799 0578823 0579151 0579177 0579565 0579573 0579599 0579607 0579615 0579623 0579631 0579649 0579664 0579672 
##      36      81     113      65      31      88      34      39      12     111      44      40      32      27 
## 0579680 0579698 0579706 0579714 0579730 0579748 0579797 0580514 0580746 0580753 0580779 0580803 0580837 0580928 
##      40      69      10      83      47      39     118     109      41      92     153      14      50      17 
## 0580977 0581710 0581728 0581736 0581744 0581777 0581876 0581884 0581892 0581900 0581991 0582114 0582122 0582148 
##      60      45      38     126     157      44     137      54      36      55      53      26     106     339 
## 0582163 0582171 0582189 0582254 0582262 0582304 0582312 0582387 0582403 0582411 0582833 0582866 0582890 0582932 
##     174     116     101     146      66     133     164      59     156      38      53      29      65     138 
## 0582981 0583013 0583021 0583088 0583104 0583203 0583328 0583443 0583476 0583500 0583534 0583567 0583591 0587485 
##      16     111     108     114     128      57      52     177      86      80      96     107     105      33 
## 0589200 0589234 0591065 0591131 0591164 0591198 0591289 0592816 0594895 0595298 0596007 0598581 0598649 0599159 
##     137      43      21     116      73      62      28      29      15      19       9      55      50     117 
## 0599365 0601492 0603878 0605469 0605501 0606392 0606459 0607143 0607531 0607549 0607556 0607697 0609883 0610683 
##      64      23      73     236     125      14     134      55      66      41     113     186     103      18 
## 0612945 0613638 0614933 0614966 0614990 0615690 0615948 0616185 0616201 0616433 0616441 0616466 0616938 0616961 
##      24      31      66      84      80      75     103      54      93      44     157      84      38       9 
## 0617183 0617191 0617209 0617217 0617233 0617290 0618447 0619361 0622456 0625830 0626374 0628842 0632471 0635284 
##      56      23      57      32      29      56      22      18      59     133      82     151      23     145 
## 0635318 0635334 0635987 0636019 0636217 0637132 0637249 0637306 0642801 0642892 0642926 0643148 0643163 0643171 
##      13     104      24     180      60      19      68      90      72     186      50     126      29      82 
## 0643221 0643262 0643668 0643692 0643783 0643817 0643841 0643874 0644690 0644880 0647057 0647065 0647172 0649129 
##      48      88      47      31      48      23      66     129      40      22     114     137      37     139 
## 0649483 0649673 0649731 0649897 0650002 0650036 0655746 0655795 0656447 0656587 0658716 0659599 0659623 0659722 
##      64      27     104      77      68      14     112      60     151      58      21      74      34     202 
## 0659896 0659953 0662940 0662957 0663005 0663096 0663112 0663120 0663138 0663153 0663534 0663542 0663559 0663971 
##      88     156      60      88      41      35      87      56      79      99      20      49      82     100 
## 0664292 0664698 0664706 0664748 0664912 0664920 0665265 0665273 0665281 0665463 0665471 0665489 0666438 0667022 
##      64     209     113     183      27      91      29      79     153     113     112     211      14     155 
## 0667394 0668764 0669341 0671073 0671438 0672600 0672618 0672626 0674374 0675025 0678581 0678615 0679670 0681452 
##     111      96      31     105      16      33      67     112      96      23      76      50      45      80 
## 0682229 0682245 0682252 0682260 0683946 0685016 0688283 0690008 0690024 0690289 0690297 0691931 0692434 0692442 
##     106      25      12     164      14     103      77      51     120      75      24     260     123      73 
## 0692459 0692467 0692707 0693382 0693499 0693622 0693630 0693655 0693663 0694539 0694547 0694554 0694562 0694570 
##      51      75      39     134     155      56      44     142      97      51     107      24      86     111 
## 0694588 0694596 0694604 0695262 0695270 0695288 0695296 0695312 0696948 0697029 0697045 0701557 0701755 0703215 
##      62      79     133      74      13      33      68      50      34      16      49      11      11      99 
## 0703223 0703231 0703249 0703256 0703744 0703751 0704072 0704460 0704593 0705053 0705160 0705459 0705509 0705772 
##      80     198     136     117     115      33      44      81      30      75      65     114      26     109 
## 0707646 0709493 0709527 0709907 0712885 0712976 0715961 0716886 0718718 0719880 0720235 0723353 0723486 0723825 
##       8      71      59      29     131      46      73      86      98      23       9      25      32      82 
## 0724815 0725523 0725739 0725770 0725861 0727461 0728055 0728196 0728337 0728717 0728907 0730515 0732321 0732339 
##      57      30      32      65      65      25      17      61     154     175      24     114      67      50 
## 0732347 0732495 0733147 0735035 0738542 0738559 0739557 0742130 0743179 0743773 0743781 0743799 0743807 0743815 
##      44      79      45      54      13      35      87      20      13      16      45      59     165      43 
## 0743831 0744045 0744565 0744573 0744870 0744888 0745448 0745745 0745752 0749325 0749358 0749366 0750083 0750125 
##      57      16      53      35      32      64      95     107     119      39      46      53      44      31 
## 0751230 0753137 0753178 0756015 0757922 0757930 0758078 0759563 0759571 0759613 0762773 0762781 0762849 0762856 
##      51      62      23       9     105      50      87      94      16      23      24      99      42     137 
## 0762864 0762880 0762906 0762914 0763169 0763771 0763789 0764910 0764928 0764936 0765297 0765305 0765313 0765321 
##     105     112     171     200      39      35       7      78      30     199      53      18     107      74 
## 0765362 0765370 0765396 0765404 0765412 0766329 0773788 0773812 0773846 0774026 0774455 0774679 0774703 0774737 
##      61     137      72      19      52     109      48      48      39      34      69     107      63      34 
## 0774760 0774794 0775320 0775346 0775874 0775908 0777243 0777656 0777680 0777714 0777995 0778001 0778027 0778233 
##     139      59     127      79     143      41     110      97     121      80      45      72      25      62 
## 0778738 0778761 0778795 0779041 0779868 0780320 0780759 0781245 0781278 0781302 0781336 0781369 0781930 0782045 
##     147      54     193     104      16      60      79      51      81      28     114     117     187      62 
## 0782078 0782102 0782664 0782680 0784512 0785097 0785873 0785956 0785964 0787473 0794412 0794438 0806653 0806943 
##      97      59      87      98      55      26      43      57       7      36      59      39     216      16 
## 0807297 0811091 0817650 0818070 0832253 0832279 0832287 0832303 0832311 0832337 0832345 0869198 0869222 0869230 
##      76     102       3      30      89      87     144      47      17     109      18      36     113      42 
## 0869248 0870931 0870949 0870956 0872515 0874198 0874206 0874214 0874222 0876375 0876383 0876409 0876417 0876433 
##     121      79      38      20      76     216     101       8      16      20      24     162     116     174 
## 0876441 0876508 0876524 0876532 0877308 0878058 0879791 0879817 0883967 0884510 0884528 0884536 0884544 0884551 
##      82     103      36      92      59      54     102      63     154      75      27      23      38      71 
## 0884569 0884577 0884585 0884593 0884601 0884619 0884627 0884635 0886218 0886226 0886234 0886242 0886259 0886309 
##      86      19     110      41      43      91     114     107      23      89      26      75     122      92 
## 0895482 0895516 0895607 0895755 0895813 0897728 0897819 0899039 0899062 0899096 0899112 0899120 0899187 0899211 
##      75      28      18      62      55      39      59      32      56      31      79      46      58      27 
## 0899237 0899294 0899328 0899336 0899369 0899393 0899419 0900647 0900670 0900704 0900738 0900761 0900795 0900829 
##      27      20      14      92      45       9      20     132      67     104      60      35     131      87 
## 0900852 0900886 0900910 0900944 0900977 0901009 0901033 0901066 0901082 0901090 0901124 0906313 0908848 0913814 
##      15      51      95      46     158     165      46      74      70     135      58      68      97      21 
## 0914085 0915256 0919308 0919332 0919365 0919456 
##     143      41      57      89      76      45 
##  [ reached getOption("max.print") -- omitted 23 entries ]
## [1] "Frequency table after encoding"
## cod_mod7. Codigo modular de la IE (Muestra DFM)
##  684  685  686  687  688  689  690  691  692  693  694  695  696  697  698  699  700  701  702  703  704  705  706 
##   51   27    9   97  182   92  133   12   92  159  187   76  232  251   27   39   21   46   31   72   56   16  190 
##  707  708  709  710  711  712  713  714  715  716  717  718  719  720  721  722  723  724  725  726  727  728  729 
##  102   63   48   44  121  151   30  128  117  156   96  100  258   23   50  115   36  106   74   23   96  111   26 
##  730  731  732  733  734  735  736  737  738  739  740  741  742  743  744  745  746  747  748  749  750  751  752 
##  430   63  169   43  217  146   72  259   96  161   57   23   78   34  162   15   57  125   75   19   14    9   91 
##  753  754  755  756  757  758  759  760  761  762  763  764  765  766  767  768  769  770  771  772  773  774  775 
##   49   98   22   82   81   82   73   54  109   83  458  114   71   93  185   42   30   48   58  111   67  171   12 
##  776  777  778  779  780  781  782  783  784  785  786  787  788  789  790  791  792  793  794  795  796  797  798 
##  135   78  136  127  123  173  116   77   19   46   46  163   94  120   48   47   79  217   38  102  471   54  103 
##  799  800  801  802  803  804  805  806  807  808  809  810  811  812  813  814  815  816  817  818  819  820  821 
##  139  206   52   19   45  121   59  105   41  178  107  188   77   39  113   31   47   27   48  430   98  162  229 
##  822  823  824  825  826  827  828  829  830  831  832  833  834  835  836  837  838  839  840  841  842  843  844 
##   82   80  188   87   16   87   56  151   60   64   61  182  111  166   97  105  171  366  153   56   33  107  105 
##  845  846  847  848  849  850  851  852  853  854  855  856  857  858  859  860  861  862  863  864  865  866  867 
##   33   67   49   71  131  113  115   71   20   22   39   23   28  219  136   26   64  228   86   34  122   95  211 
##  868  869  870  871  872  873  874  875  876  877  878  879  880  881  882  883  884  885  886  887  888  889  890 
##  104   88   62   82  100   56  266   24   79   46   68   31   88   27  131   55   32   63   66  128   24  105   85 
##  891  892  893  894  895  896  897  898  899  900  901  902  903  904  905  906  907  908  909  910  911  912  913 
##   72  186  369   80   23  106  152  196  120  209  219  188  115   42   14   71   29   27   36   56  236  245  123 
##  914  915  916  917  918  919  920  921  922  923  924  925  926  927  928  929  930  931  932  933  934  935  936 
##   35   68   23   37   55   92   77  109   66   51   74  184   51   94  145  286   34   58   33   87  117  110  233 
##  937  938  939  940  941  942  943  944  945  946  947  948  949  950  951  952  953  954  955  956  957  958  959 
##   14  110  128   32  137   34   40  174   54  126   89   99   38  216   72  114   39   62   55   82   99   23  101 
##  960  961  962  963  964  965  966  967  968  969  970  971  972  973  974  975  976  977  978  979  980  981  982 
##  104   87  185  280    8   27   27  134  202   75  415   13   78  131   13   75  156   11  145   48  165   14   95 
##  983  984  985  986  987  988  989  990  991  992  993  994  995  996  997  998  999 1000 1001 1002 1003 1004 1005 
##   69  104  145  107   81   98   52   86  178   13   57   64   30   40  356   92   96   88   51  112   71   81  351 
## 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 
##  107   11   29  112   67   19  137   97   27  103   28  184  135   28  317   76   50  188   29   17  157   38   68 
## 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 
##   55   21  122   24   68   18  304   16  133   30   62   82  143   19   61   51  179   23   46   43   24  266   25 
## 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 
##   84  147  119  200  278  124  295  160   65   42   91  160   87  109  119   58   50   46   35   49   42   14  149 
## 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 
##   65   10   41   34  112   32   39   79   14   94   16   68  155   66   63  130  144    9  183   48   70  219  464 
## 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 
##  193   58   37  117   73  157  218  122   54   82   66  116   46   24   59   37   55  300  199   32   17   88   72 
## 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 
##   27   20  182   19    9  127  312   89  156   16   18   34   20   46  205   51  166   59  122   16   59  109   40 
## 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 
##  126  111   69   18   70  180   57  133   86   39   88  185  138   64   65  127  117   25   10   30   69  164   35 
## 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 
##   39   47  106   59   59   32  339  114  177   68  244  112  142   16   41   30   50   20   31  383  103  167   79 
## 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 
##   76  112   95  250   18   50  137   39   39   93   36   62   20  154   25  136  191  181  263  120  126   68  149 
## 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 
##  359  108  158  103   79  162   42  258  113  162  193   24  146   19   47   15   16   92   69  168    7   67   29 
## 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 
##    8   22   40   66   80   64   36   20  159   87  198  147   87   29  128  267   14   67   55   80   45   21   36 
## 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 
##   26   31   83   12   67  219   38   16   62  269  370   74  114  152   30   83   89  116   26   44   60   61   60 
## 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 
##   60   74   75  116   76   44   63  117   61   88   52   46  101  101   88   59   86   32   13   33   26   86  108 
## 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 
##   65   62  160  118  113  114  218   59   11   18   90  226   53   11   35  143   34    9    5  294   36   12   74 
## 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 
##  104   23   79  236   45   25  475   75   41   50  111   81  200  207   35   46  114  143   58  238   75   65  381 
## 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 
##   48   29   88   16  399  112   53   77   35   48  139  139   13  211   16   21  106  260  144   23   65   99  114 
## 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 
##   87   15   13   75  145   58  157  133   17  216  135   15   24    3  102  125  152  104  232   93   16   81   36 
## 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 
##  104  103  226   45  280   23  161   83   60   77   45   80  193   45   19  156   56  107   56  214  165  223   41 
## 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 
##  109  215   88   15  254  142   99   63   56   66  249   25   49  175   65  207   47  149  179   39   53  224   60 
## 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 
##  103   60   42  186  116  107   22   37   67    9   67   91  292   52  164   10   82  154  290   59   73   67   92 
## 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 
##   56   24   45  177   76   76   27   46   31  244   16   56   34   96  129    7   41  286  277   61   57  183   43 
## 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 
##  216  104   41   28   36   50  176  284  151   76   45   58  174   68   86  305   41  107  161   66   32   57  239 
## 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 
##  145  138  132   55   91  313   79   43   33   44  100   43   97  129   27  104  261  154   60  238   24   71  208 
## 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 
##   31    7   59  224  117  183   46   98  155   97   41   27   66  198  131   85  367  427   54   84   12  110   60 
## 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 
##  153   20   79  150  113  226   23   55   23  129  115   89   59   24   56   59  187   33  107   91   54   75   23 
## 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 
##  468   59  169   53   73  164  109  137   73  109   25  175   39   41   44  105  174  101  189   79   27  137   29 
## 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 
##  153   81   46   59   27  373   45   81  258  155  108   56   66  121  107   92  113   26  155   99   38   44   30 
## 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 
##   61  107  174   20  509   36   29   38   29  110  145  235   44  126   13   54  202   32  101   49   53   75   15 
## 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 
##   56   98  118   63   75   40   23  143   97  195   57   70  137  102  137  139   28   19  111   57   71  389  171 
## 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 
##   91  119   61   39   58   59   13   15   82  156   73 
##  [ reached getOption("max.print") -- omitted 23 entries ]

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

# !!!No Indirect PII - Ordinal

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

# !!!No Indirect PII - Categorical

Matching and crosstabulations: Run automated PII check

# !!!Insufficient demographic data

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

# !!!No Open-ends

GPS data: Displace

# !!!No GPS data

Save processed data in Stata and SPSS format

range <- 1:length(names(mydata))

for (i in range){
  names(mydata)[i]=gsub("[[:punct:]]", "", names(mydata)[i])
}


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)