rm(list=ls(all=t))

Setup filenames

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

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

#mydata <- read.csv (paste0(filename, ".csv"))
#haven::write_dta(mydata, 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 0207506 0209270 0209304 0209387 0209510 0209528 0209536 0209908 0209916 0209924 0209940 0209965 
##       5       4       1       2       1       8       6       1      10      14       2      19       3      16 
## 0233056 0233064 0233130 0236117 0236174 0236182 0236349 0236414 0236778 0238667 0238675 0238808 0238840 0239798 
##      13       1       2       1       3       2       6      24       4       5       2      10      24       3 
## 0239814 0239822 0240184 0240267 0242271 0242289 0245647 0245654 0245662 0245670 0245688 0245696 0262188 0273516 
##       2       1       5      13       4      14       3      16       3       4       6       9      14      20 
## 0273524 0275438 0275479 0275545 0275552 0275719 0290569 0290585 0290601 0290619 0290874 0290890 0302711 0302885 
##       2       4       1       2      19      16      32      22       6       3      12       6       1      29 
## 0302893 0302943 0302950 0302968 0304444 0309229 0309260 0309302 0309377 0309401 0309435 0309492 0309500 0309526 
##      15       1      26      26      13       7      15       2       1       1       7       6       1       1 
## 0309641 0309682 0309773 0309799 0309807 0309823 0309856 0310516 0322479 0323345 0324772 0325449 0325456 0325464 
##       2       1      15       2       3       1       1       1       8       5       1       4       6       6 
## 0325472 0325480 0325498 0325506 0325548 0325555 0325589 0325597 0325605 0325613 0325621 0325639 0325647 0325654 
##      13       5      14       1       7       2       5       2       3       8      16       2      12       1 
## 0325696 0325704 0325712 0327379 0327486 0327650 0329326 0329573 0329755 0329805 0334649 0334656 0334664 0334706 
##       8      20       4       4       3       3       2       6       4       2      20      10       8       6 
## 0334722 0334730 0334748 0334771 0336495 0336586 0336594 0336610 0336628 0336636 0336891 0337436 0337568 0337592 
##      12       3       6       2       4      21      16      12      17       1      22      12      10       4 
## 0337717 0337733 0340224 0340281 0340299 0340315 0340323 0340331 0340356 0340364 0340398 0340414 0340430 0340448 
##       3       2       3       1       4       7       2       1       1       4       1       6      14      14 
## 0340463 0343566 0355875 0355990 0356071 0356089 0356188 0356758 0372508 0372540 0372565 0372581 0372599 0372680 
##       1      10       2      30       5      11      12       2      16      14      18      18      46      10 
## 0372698 0373761 0373787 0375758 0390591 0390609 0390690 0390708 0391060 0391078 0394353 0394445 0394775 0394825 
##       1      28      10       5      59      11       5      19      10       6       1       3      13       8 
## 0395061 0395079 0395087 0395103 0395111 0395152 0395228 0395236 0395251 0395269 0411736 0421248 0421396 0424507 
##       5       3      12       6       4       1      20       1       2      18       5       7       7      27 
## 0424523 0424572 0424580 0424606 0424770 0427690 0427716 0432773 0436642 0437210 0437228 0437236 0437244 0437251 
##       5       4       6       8       1       3       1       4       1       2      11       3      13       7 
## 0437269 0437277 0437285 0437293 0437319 0437327 0437335 0437343 0437350 0437368 0437509 0437517 0437525 0437541 
##      21       6       4       6       6       2       6      18      11       1       5      11       3       2 
## 0437707 0437715 0437723 0437731 0437772 0449819 0449827 0449868 0452565 0452573 0452599 0452623 0452631 0452649 
##       5       7       1       7       1       6       1       6      24      10       8       2       4      32 
## 0452656 0452722 0452730 0452748 0452763 0452771 0452847 0452854 0453597 0453605 0453647 0466383 0466722 0469205 
##       2       6       1       8       1       2       3      10      15      12       2       1       2      18 
## 0469700 0478479 0481184 0481820 0481903 0482042 0488619 0488635 0489096 0492769 0492876 0493544 0493635 0493742 
##       3       4       5       5       2       1       3       1       5       3       5      14      15       8 
## 0493841 0494070 0495150 0495259 0495424 0495762 0495812 0496166 0496265 0498782 0498824 0498998 0499699 0500124 
##       5       1       1       3       8       5       6       1       2       1      10       9      10       4 
## 0500611 0501411 0501502 0501676 0501700 0501809 0501908 0502047 0502336 0502435 0502484 0502633 0504993 0505149 
##       4       1      15       1       2       2       2       4       1       6       2       6       5       9 
## 0507806 0508168 0508267 0515668 0516963 0519645 0520064 0520486 0521179 0522318 0522862 0523423 0523431 0523472 
##       1       1       9       1       7      16       6      13       8       6       8       2       1       3 
## 0523621 0524637 0533752 0535724 0535823 0535930 0536029 0536128 0536151 0536326 0536714 0537761 0542357 0544957 
##      11       7       9       7       7       9       3       5      11       3      10       5       5      10 
## 0545053 0545251 0545459 0546002 0546986 0547083 0547877 0547976 0552612 0553412 0553511 0553529 0554824 0555847 
##      29       1       7       1       4      11       4      12       7       1       1       3       6       1 
## 0555862 0555946 0556266 0556340 0556449 0556472 0556571 0564252 0565143 0565176 0565200 0565234 0565267 0566141 
##       1       7       1       2       1       1       8       1       5       3      10       1       2       6 
## 0566158 0566166 0566414 0566422 0566430 0566448 0566455 0566463 0566471 0566927 0566950 0567743 0567750 0568592 
##       5       1       1       2       1       6       2       1       7       1       1       2       1       2 
## 0568618 0568915 0569053 0569566 0569988 0570010 0570044 0570648 0571620 0572032 0572768 0573352 0577346 0577379 
##       8       3       3       2       1       5       2       1       4       4       1       1       8       2 
## 0577387 0577486 0577783 0577817 0577825 0577833 0577841 0577858 0577866 0577874 0577882 0577890 0577908 0577916 
##       8      10       4      10       6       2       8       9      16       2       1       2      11       5 
## 0578260 0578278 0578286 0578294 0578336 0578393 0578401 0578435 0578443 0578450 0578468 0578500 0578518 0578526 
##       5       8      15       3       2       1       3       4      10      12       1      14       3       7 
## 0578534 0578542 0578559 0578773 0578823 0579565 0579623 0579680 0579698 0579714 0579730 0579797 0580514 0580746 
##       3       4       2       4       1       5       1       4       2       2       3       2       2       2 
## 0580753 0580779 0580837 0580928 0580977 0581710 0581728 0581744 0581777 0581876 0581892 0581900 0581991 0582122 
##       6       1       2       2       3       2       3       7       8      23       1       6       4      11 
## 0582148 0582163 0582171 0582189 0582254 0582262 0582304 0582312 0582403 0582833 0582866 0582890 0582932 0583013 
##      48       5       2       3      14       1       5       4       5       5       3       1       2       7 
## 0583021 0583088 0583104 0583328 0583443 0583476 0583500 0583567 0583591 0589200 0589234 0591065 0591164 0595298 
##      16       4       9       2       8       3       5       3       2       3       2       2       1       5 
## 0598581 0599159 0599365 0601492 0603878 0605469 0605501 0606392 0606459 0607143 0607531 0607556 0607697 0610683 
##       1      15       1       3       6      10      14       2      11       4       1      10      31       1 
## 0613638 0614933 0614966 0614990 0615690 0615948 0616201 0616441 0616466 0616938 0617191 0622456 0625830 0626374 
##       1       2       1       1       4       7       2       3       6       1       1       4       7      16 
## 0628842 0632471 0635284 0635334 0636019 0637249 0639922 0642801 0642892 0642926 0643148 0643163 0643171 0643262 
##       3       3      10       4       3       5       1       4      12       2       1       2       4       5 
## 0643668 0643817 0643841 0643874 0644690 0644880 0647057 0647065 0647172 0649129 0649483 0649731 0650002 0655746 
##       1       1       1      11       4       1       2       5       1       5       5       2       7       2 
## 0655795 0656447 0656587 0659599 0659623 0659722 0659896 0659953 0662940 0662957 0663005 0663096 0663112 0663138 
##       1       4      13       1       5      23      13       6       6       5       3       2       5       1 
## 0663153 0663534 0663559 0663971 0664292 0664698 0664748 0664912 0664920 0665265 0665273 0665281 0665463 0665471 
##       4       5       1       4       3       8       3       4       5       3       1       2      13       9 
## 0665489 0667394 0671073 0672618 0672626 0674374 0675025 0678581 0679670 0681452 0682229 0682245 0682260 0685016 
##       8       4       2       1      16       1       1       1       1      11       2       1      13      19 
## 0688283 0690008 0690024 0690289 0690297 0691931 0692434 0692442 0692459 0692707 0693382 0693499 0693622 0693630 
##       3       1       1       3       3      12       3       5       2       2       3       1       4       6 
## 0693655 0694539 0694547 0694554 0694562 0694570 0694588 0694604 0696948 0703215 0703223 0703231 0703249 0703256 
##      12       1       4       2       5       7       3       7       2       7      13       4       8       4 
## 0703744 0703751 0704460 0704593 0705160 0705459 0705772 0709493 0709527 0712885 0715961 0716886 0718718 0720235 
##       2       1       4       2       8       2       4       2       1       2       7       5       3       1 
## 0723825 0725523 0725739 0725770 0725861 0728055 0728196 0728337 0728717 0728907 0732321 0732339 0732347 0733147 
##       4       2       2       6       2       1       3       7      10       1       2       6       7       1 
## 0735035 0738542 0738559 0739557 0743179 0743773 0743781 0743799 0743807 0743831 0744565 0744573 0744888 0745448 
##       5       1       3       4       1       1       4       5      18       1       3       1       5       2 
## 0745745 0745752 0749366 0750125 0751230 0753137 0757930 0758078 0759563 0759571 0762773 0762781 0762849 0762856 
##      12       5       1       1       6       3       3       5       3       1       3       1       2       6 
## 0762864 0762880 0762906 0762914 0763771 0764928 0764936 0765297 0765313 0765321 0765362 0765370 0765396 0765404 
##       7       6       6      15       1       1      10       2       5       5       3      16       1       2 
## 0766329 0773788 0773812 0774455 0774679 0774703 0774737 0774760 0775320 0775346 0775874 0775908 0777243 0777656 
##       6       1       4       3       4       6       3       5       1       6       2       1       2       4 
## 0777680 0777714 0777995 0778001 0778027 0778233 0778738 0778761 0778795 0779041 0779868 0780320 0780759 0781278 
##       4       4       4       1       2       1       4       1      17      10       1       3       6       5 
## 0781302 0781336 0781369 0781930 0782045 0782078 0782102 0782664 0784512 0785873 0785956 0785964 0806653 0807297 
##       4      11       4       5       3       2       4       2       3       4      12       1       4       2 
## 0811091 0832253 0832287 0832303 0832311 0832337 0869198 0869222 0869230 0870931 0870949 0870956 0872515 0874198 
##       3       3       3       3       1       6       2       9       2       2       3       2       3       9 
## 0874206 0874214 0876409 0876433 0876441 0876532 0878058 0879791 0879817 0883967 0884536 0884544 0884569 0884577 
##       7       1       9       1       2       1       3       1       6      13       1       4       7       3 
## 0884585 0884593 0884601 0884619 0884627 0884635 0886218 0886226 0886234 0886309 0895482 0895607 0895813 0899112 
##       2       2       1       2       3       3       1       1       1       1       3       2       1       4 
## 0899120 0899336 0899369 0900647 0900704 0900738 0900761 0900795 0900829 0900852 0900886 0900910 0900944 0900977 
##       1       8       2       9       8       1       5      13       3       1       4       1       2      13 
## 0901009 0901033 0901066 0901090 0901124 0906313 0913814 0914085 0919308 0919332 0919365 0919456 0919480 0919514 
##       8       4       6       8       3       1       4       9       1       1       1       1       5       7 
## 0921775 0922054 0922872 0923136 0923482 0927814 0927848 0929976 0930537 0933598 0935635 0935668 0935692 0938605 
##       5      12      10       3       1       2       4       1       2       7       2       6       2       6 
## 0938639 0938662 0938696 0939942 
##       1       4       1       4 
## [1] "Frequency table after encoding"
## cod_mod7. Codigo modular de la IE (Muestra DFM)
##  664  665  666  667  668  669  670  671  672  673  674  675  676  677  678  679  680  681  682  683  684  685  686 
##    1    3    3    1    8    3    2    6    1    5   11    6    1    6    4   11    6    5    1    7   18    5   32 
##  687  688  689  690  691  692  693  694  695  696  697  698  699  700  701  702  703  704  705  706  707  708  709 
##    3    7    2    1    2   13   10    1    1    3    1    1    2    2    1    5    4    1    9    3   15   14    1 
##  710  711  712  713  714  715  716  717  718  719  720  721  722  723  724  725  726  727  728  729  730  731  732 
##    1   20    1    4    1    1    2    2    2    6    1    7    1    2    3    5   15    5    1    3    5    5    6 
##  733  734  735  736  737  738  739  740  741  742  743  744  745  746  747  748  749  750  751  752  753  754  755 
##    3   14    1    2    3    4    3    6    9    2   10    7   14    1    6   15    1   11   14    1    8    2    2 
##  756  757  758  759  760  761  762  763  764  765  766  767  768  769  770  771  772  773  774  775  776  777  778 
##    9    8   18    5    2    1   23    8    3   12    4    2    3    1    4    2    1    2    3   13    1    4    1 
##  779  780  781  782  783  784  785  786  787  788  789  790  791  792  793  794  795  796  797  798  799  800  801 
##   10   14    1    2    2    8    1   13    4   17   16    6    1   10    3    1    3    6    2    7    1   10    2 
##  802  803  804  805  806  807  808  809  810  811  812  813  814  815  816  817  818  819  820  821  822  823  824 
##   10   10    6    2    1    4    5   15    8    8    2    6   31    6    2    8    3   13    7   21    2   16    4 
##  825  826  827  828  829  830  831  832  833  834  835  836  837  838  839  840  841  842  843  844  845  846  847 
##    2    5    4    3    5    4    2    1    1    6    3    6   10    4    7    7    1   14   12    2    1    2    1 
##  848  849  850  851  852  853  854  855  856  857  858  859  860  861  862  863  864  865  866  867  868  869  870 
##    3    2    6   10   18    7   19    7    3    2    1    3    1    5    2    4    1    8   10    5    1    2    1 
##  871  872  873  874  875  876  877  878  879  880  881  882  883  884  885  886  887  888  889  890  891  892  893 
##    5    2    1    2    2    2    8    4    6    5   11   10    1    6    1    1    3    1    2    5    1    3    2 
##  894  895  896  897  898  899  900  901  902  903  904  905  906  907  908  909  910  911  912  913  914  915  916 
##    4    7    9    5   12    2    4    7    4    3    2    1    2    2   10    6   11    6    5    1    3    5   22 
##  917  918  919  920  921  922  923  924  925  926  927  928  929  930  931  932  933  934  935  936  937  938  939 
##    4    1    1   12    4    1    8    2   12    5    4    2   11    7    4    2    2    3    2    1    8    3    2 
##  940  941  942  943  944  945  946  947  948  949  950  951  952  953  954  955  956  957  958  959  960  961  962 
##    2    4   10    5   13    5   10    6    3    7    2    2    2    1   10    4    4    1    4    2    3    2   10 
##  963  964  965  966  967  968  969  970  971  972  973  974  975  976  977  978  979  980  981  982  983  984  985 
##    2    1    4    8    2    5    3    6   59    1    3    3    2    4    1    4   19    2    1    8    2    4   19 
##  986  987  988  989  990  991  992  993  994  995  996  997  998  999 1000 1001 1002 1003 1004 1005 1006 1007 1008 
##    3   20    9    2    4    1    3    1    3    6    5    6   11    2    6    3    1   12    4    4    6   10   23 
## 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 
##    2    7    6    2    7    2    1    1    1    1    1   12    1    3    4    5    2    6    5    6    1   10    5 
## 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 
##    6    3    9    5    3    4   12    7    4    4   11    2    3    3   16    1    3    4   18    1    5    1    3 
## 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 
##   15    6    1   14   13    1    1    6    4    3    7    3    5    3    1    3    1    4    4    3    1   10   16 
## 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 
##    6    2    2    6    4   20    1   29    2    1    2   12    4   15    1    2    1   16    3    1    4    2    3 
## 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 
##    7    5   10   14    5    3   18    1    1    2    7    1    2    2    6    4   16    1    1    8    6    5    6 
## 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 
##    2    9    1    1    2    4    8    1    1    5    1   13    1    8    1    1    7    3    6    1   27    7    5 
## 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 
##    5    1    1   11    3    7    7    3    1    1    2    2    5    2    1    1    1    1    4   15    1   14    2 
## 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 
##   10    5    4    7    1    1    5    7    3    5    1    2    2   16    1   16    2   20    1    1    8    4    4 
## 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 
##   16    2    7    7    9    2   17    3   13    6    1    4    2   21    6    1    2    2    1    2    5   11   13 
## 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 
##    5    5    2    1    5   26    1    1    3    4   15    1    4    3    1   12    4    7   14   28   11   10    1 
## 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 
##    8    4    1    2   26    1    2   12    1    3    5    6    1    4    4    4    4    1    6    7    3    3    5 
## 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 
##    3    9   13    1    3   24    7    9    8    8    2   30    6    4    3    8    8    2    1    8    6    2   48 
## 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 
##    1    1    2   29    6    1    1    1    1    4   16    2    1    1   13    3    2    1    1    1    1    5    2 
## 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 
##    9   15    2    3    4    4    1   10    5    6    2    1    9    6    8    2    7    5    8    5    3    3    3 
## 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 
##   18    8    5    4    1    2    6    4    7    3    3    2    2   22    5    3    4    5    1   11    6    1    2 
## 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 
##   13    6    2    3    1    3    7    2    1    1    1    4   16    3    3    3    5   10   14    5    4   19    2 
## 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 
##   12    1   11   12   11    2    4    3    6   12   10    3   13   12    5    1    5   32   16    1   13   12    6 
## 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 
##    3    9    5    4    2    5    1    4    3    3    8    1   13    4    1    5    9    4    1    1    5   46    8 
## 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 
##    3    2    1    4   24    1    1    1    6   24    3    1    1    2    4

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

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)