diff --git a/Indicators/SchoolBasedProgrammes-CRF93-SchoolAbseentism/SBP_CRF93_Abseentism.sps b/Indicators/SchoolBasedProgrammes-CRF93-SchoolAbseentism/SBP_CRF93_Abseentism.sps index 77d6721..013d4eb 100644 --- a/Indicators/SchoolBasedProgrammes-CRF93-SchoolAbseentism/SBP_CRF93_Abseentism.sps +++ b/Indicators/SchoolBasedProgrammes-CRF93-SchoolAbseentism/SBP_CRF93_Abseentism.sps @@ -1,158 +1,27 @@ * Encoding: UTF-8. -*can only download repeat csv data as zip file from moda with group names - will update this code to remove group names -*rename to remove group names - because of the variable length SPSS changes name slightly +*this syntax is based on SPSS download version from MoDA -RENAME VARIABLES (Nutrition_moduleMDD_W_submoduleRepeatMDDWPWMDDWStapCer = PWMDDWStapCer). -RENAME VARIABLES (Nutrition_moduleMDD_W_submoduleRepeatMDDWPWMDDWStapRoo = PWMDDWStapRoo). -RENAME VARIABLES (Nutrition_moduleMDD_W_submoduleRepeatMDDWPWMDDWPulse = PWMDDWPulse). -RENAME VARIABLES (Nutrition_moduleMDD_W_submoduleRepeatMDDWPWMDDWNuts = PWMDDWNuts). -RENAME VARIABLES (Nutrition_moduleMDD_W_submoduleRepeatMDDWPWMDDWMilk = PWMDDWMilk). -RENAME VARIABLES (Nutrition_moduleMDD_W_submoduleRepeatMDDWPWMDDWDairy = PWMDDWDairy). -RENAME VARIABLES (Nutrition_moduleMDD_W_submoduleRepeatMDDWPWMDDWPrMeatO = PWMDDWPrMeatO). -RENAME VARIABLES (Nutrition_moduleMDD_W_submoduleRepeatMDDWPWMDDWPrMeatF = PWMDDWPrMeatF). -RENAME VARIABLES (Nutrition_moduleMDD_W_submoduleRepeatMDDWPWMDDWPrMeatPro = PWMDDWPrMeatPro). -RENAME VARIABLES (Nutrition_moduleMDD_W_submoduleRepeatMDDWPWMDDWPrMeatWhite = PWMDDWPrMeatWhite). -RENAME VARIABLES (Nutrition_moduleMDD_W_submoduleRepeatMDDWPWMDDWPrFish = PWMDDWPrFish). -RENAME VARIABLES (Nutrition_moduleMDD_W_submoduleRepeatMDDWPWMDDWPrEgg = PWMDDWPrEgg). -RENAME VARIABLES (Nutrition_moduleMDD_W_submoduleRepeatMDDWPWMDDWVegGre = PWMDDWVegGre). -RENAME VARIABLES (Nutrition_moduleMDD_W_submoduleRepeatMDDWPWMDDWVegOrg = PWMDDWVegOrg). -RENAME VARIABLES (Nutrition_moduleMDD_W_submoduleRepeatMDDWPWMDDWFruitOrg = PWMDDWFruitOrg). -RENAME VARIABLES (Nutrition_moduleMDD_W_submoduleRepeatMDDWPWMDDWVegOth = PWMDDWVegOth). -RENAME VARIABLES (Nutrition_moduleMDD_W_submoduleRepeatMDDWPWMDDWFruitOth = PWMDDWFruitOth). -RENAME VARIABLES (Nutrition_moduleMDD_W_submoduleRepeatMDDWPWMDDWSnf = PWMDDWSnf). -RENAME VARIABLES (Nutrition_moduleMDD_W_submoduleRepeatMDDWPWMDDWFortFoodoil = PWMDDWFortFoodoil). -RENAME VARIABLES (Nutrition_moduleMDD_W_submoduleRepeatMDDWPWMDDWFortFoodwflour = PWMDDWFortFoodwflour). -RENAME VARIABLES (Nutrition_moduleMDD_W_submoduleRepeatMDDWPWMDDWFortFoodmflour = PWMDDWFortFoodmflour). -RENAME VARIABLES (Nutrition_moduleMDD_W_submoduleRepeatMDDWPWMDDWFortFoodrice = PWMDDWFortFoodrice). -RENAME VARIABLES (Nutrition_moduleMDD_W_submoduleRepeatMDDWPWMDDWFortFooddrink = PWMDDWFortFooddrink). -RENAME VARIABLES (Nutrition_moduleMDD_W_submoduleRepeatMDDWPWMDDWFortFoodother_A = PWMDDWFortFoodother). -RENAME VARIABLES (Nutrition_moduleMDD_W_submoduleRepeatMDDWPWMDDWFortFoodother = PWMDDWFortFoodother_oth). +* Filter dataset for children registered to attend school. +SELECT IF (PChildRegisterSchool = 1). -Variable labels PWMDDWStapCer "Foods made from grains". -Variable labels PWMDDWStapRoo "White roots and tubers or plantains". -Variable labels PWMDDWPulse "Pulses (beans, peas and lentils)". -Variable labels PWMDDWNuts "Nuts and seeds". -Variable labels PWMDDWMilk "Milk". -Variable labels PWMDDWDairy "Milk products". -Variable labels PWMDDWPrMeatO "Organ meats". -Variable labels PWMDDWPrMeatF "Red flesh meat from mammals". -Variable labels PWMDDWPrMeatPro "Processed meat". -Variable labels PWMDDWPrMeatWhite "Poultry and other white meats". -Variable labels PWMDDWPrFish "Fish and Seafood". -Variable labels PWMDDWPrEgg "Eggs from poultry or any other bird". -Variable labels PWMDDWVegGre "Dark green leafy vegetable". -Variable labels PWMDDWVegOrg "Vitamin A-rich vegetables, roots and tubers". -Variable labels PWMDDWFruitOrg "Vitamin A-rich fruits". -Variable labels PWMDDWVegOth "Other vegetables". -Variable labels PWMDDWFruitOth "Other fruits". -Variable labels PWMDDWSnf "Specialized Nutritious Foods (SNF) for women". -Variable labels PWMDDWFortFoodoil "Fortified oil". -Variable labels PWMDDWFortFoodwflour "Fortified wheat flour". -Variable labels PWMDDWFortFoodmflour "Fortified maize flour". -Variable labels PWMDDWFortFoodrice "Fortified Rice". -Variable labels PWMDDWFortFooddrink "Fortified drink". -Variable labels PWMDDWFortFoodother "Other:". -Variable labels PWMDDWFortFoodother_oth "Other: please specify: ____________". +* Compute a variable for absence due to ill health as a binary indicator. +COMPUTE AbsentDueToIllHealth = (PChildDayAbsSchoolWhy.1 = 1). -Value labels PWMDDWStapCer,PWMDDWStapRoo,PWMDDWPulse,PWMDDWNuts,PWMDDWMilk,PWMDDWDairy,PWMDDWPrMeatO,PWMDDWPrMeatF,PWMDDWPrMeatPro,PWMDDWPrMeatWhite,PWMDDWPrFish, - PWMDDWPrEgg,PWMDDWVegGre,PWMDDWVegOrg,PWMDDWFruitOrg,PWMDDWVegOth,PWMDDWFruitOth,PWMDDWSnf,PWMDDWFortFoodoil,PWMDDWFortFoodwflour,PWMDDWFortFoodmflour,PWMDDWFortFoodrice,PWMDDWFortFooddrink,PWMDDWFortFoodother 1 'Yes' 0 'No '. +* Aggregate data to calculate total registered and total absent due to ill health. +DATASET DECLARE AggregatedData. +AGGREGATE OUTFILE='AggregatedData' + /BREAK= + /TotalRegistered = N + /TotalAbsentDueToIllHealth = SUM(AbsentDueToIllHealth). -*Calculate 2 MDDW indicators based on https://docs.wfp.org/api/documents/WFP-0000140197/download/ pg.8 -*Standard MDDW Indicator for population based surveys - counts SNF in home group (refer to https://docs.wfp.org/api/documents/WFP-0000139484/download/ for "home group") -*WFP Modified MDDW WFP programme monitoring - counts SNF in "Meat, poultry and fish" Category - -*Standard MDDW method - in this example SNF home group will be grains -*in this example all - PWMDDWFortFoodwflour,PWMDDWFortFoodmflour,PWMDDWFortFoodrice,PWMDDWFortFooddrink will also count in grains -*classifying PWMDDWFortFoodother_oth will likely involve classifying line by line - -Compute MDDW_Staples = 0. -if (PWMDDWStapCer) = 1 | (PWMDDWStapRoo) = 1 | (PWMDDWSnf = 1) | (PWMDDWFortFoodwflour = 1) | (PWMDDWFortFoodmflour = 1) | (PWMDDWFortFoodrice = 1) | (PWMDDWFortFooddrink = 1) MDDW_Staples= 1. -compute MDDW_Pulses = 0. -if (PWMDDWPulse = 1) MDDW_Pulses = 1. -Compute MDDW_NutsSeeds = 0. -if (PWMDDWNuts = 1) MDDW_NutsSeeds = 1. -Compute MDDW_Dairy = 0. -if (PWMDDWDairy = 1) | (PWMDDWMilk = 1) MDDW_Dairy = 1. -Compute MDDW_MeatFish = 0. -if (PWMDDWPrMeatO = 1) | (PWMDDWPrMeatF = 1) | (PWMDDWPrMeatPro = 1) | (PWMDDWPrMeatWhite = 1) | (PWMDDWPrFish = 1) MDDW_MeatFish = 1. -Compute MDDW_Eggs = 0. -if (PWMDDWPrEgg = 1) MDDW_Eggs = 1. -Compute MDDW_LeafGreenVeg = 0. -if (PWMDDWVegGre = 1) MDDW_LeafGreenVeg = 1.. -Compute MDDW_VitA = 0. -if (PWMDDWVegOrg = 1) | (PWMDDWFruitOrg = 1) MDDW_VitA = 1. -Compute MDDW_OtherVeg = 0. -if (PWMDDWVegOth = 1) MDDW_OtherVeg = 1. -Compute MDDW_OtherFruits = 0. -if (PWMDDWFruitOth = 1) MDDW_OtherFruits = 1. - - -*WFP MDDW method for program monitoring - SNF will count in the meats group -*in this example all - PWMDDWFortFoodwflour,PWMDDWFortFoodmflour,PWMDDWFortFoodrice,PWMDDWFortFooddrink will also count in grains -*classifying PWMDDWFortFoodother_oth will likely involve classifying line by line - -compute MDDW_Staples_wfp = 0. -if (PWMDDWStapCer) = 1 | (PWMDDWStapRoo) = 1 | (PWMDDWFortFoodwflour = 1) | (PWMDDWFortFoodmflour = 1) | (PWMDDWFortFoodrice = 1) | (PWMDDWFortFooddrink = 1) MDDW_Staples_wfp = 1. -Compute MDDW_Pulses_wfp = 0. -if (PWMDDWPulse = 1) MDDW_Pulses_wfp = 1. -Compute MDDW_NutsSeeds_wfp = 0. - if (PWMDDWNuts = 1) MDDW_NutsSeeds_wfp = 1. -Compute MDDW_Dairy_wfp = 0. -if (PWMDDWDairy = 1) | (PWMDDWMilk = 1) MDDW_Dairy_wfp = 1. -Compute MDDW_MeatFish_wfp = 0. - if (PWMDDWPrMeatO = 1) | (PWMDDWPrMeatF = 1) | (PWMDDWPrMeatPro = 1) | (PWMDDWPrMeatWhite = 1) | (PWMDDWPrFish = 1) | (PWMDDWSnf = 1) MDDW_MeatFish_wfp = 1. -Compute MDDW_Eggs_wfp = 0. -if (PWMDDWPrEgg = 1) MDDW_Eggs_wfp = 1. -compute MDDW_LeafGreenVeg_wfp = 0. -if (PWMDDWVegGre = 1) MDDW_LeafGreenVeg_wfp = 1 . -Compute MDDW_VitA_wfp = 0. -if (PWMDDWVegOrg = 1) | (PWMDDWFruitOrg = 1) MDDW_VitA_wfp= 1. -Compute MDDW_OtherVeg_wfp = 0. -if (PWMDDWVegOth = 1) MDDW_OtherVeg_wfp = 1. -Compute MDDW_OtherFruits_wfp = 0. -if (PWMDDWFruitOth = 1) MDDW_OtherFruits_wfp = 1. - - - - -*calculate MDDW variable for both methods by adding together food groups and classifying whether the woman consumed 5 or more food groups - -*Standard MDDW method where SNF is counted in grains - -compute MDDW = sum(MDDW_Staples ,MDDW_Pulses ,MDDW_NutsSeeds ,MDDW_Dairy ,MDDW_MeatFish ,MDDW_Eggs ,MDDW_LeafGreenVeg ,MDDW_VitA ,MDDW_OtherVeg ,MDDW_OtherFruits). - -*count how many women consumed 5 or more groups - -Compute MDDW_5 = 0. -if (MDDW >= 5) MDDW_5 = 1. -Value labels MDDW_5 1 '>=5' 0 '<5 '. - -Value labels MDDW_5 1 '>=5' 0 '<5 '. - - - -*WFP MDDW method for program monitoring - SNF will count in the meats group - -compute MDDW_wfp = sum(MDDW_Staples_wfp,MDDW_Pulses_wfp ,MDDW_NutsSeeds_wfp ,MDDW_Dairy_wfp ,MDDW_MeatFish_wfp ,MDDW_Eggs_wfp ,MDDW_LeafGreenVeg_wfp ,MDDW_VitA_wfp ,MDDW_OtherVeg_wfp ,MDDW_OtherFruits_wfp). - -*count how many women consumed 5 or more groups - - -Compute MDDW_5_wfp = 0. -if (MDDW_wfp >= 5) MDDW_5_wfp = 1. -Value labels MDDW_5_wfp 1 '>=5' 0 '<5 '. - -Value labels MDDW_5_wfp 1 '>=5' 0 '<5 '. - - -*Frequency of Standard MDDW Method - MDDW_5 - -freq MDDW_5. - - -*Frequency of WFP MDDW method for program monitoring - MDDW_5_wfp - -freq MDDW_5_wfp. +* Compute the percentage of absences due to ill health. +DATASET ACTIVATE AggregatedData. +COMPUTE PercentAbsentDueToIllHealth = (TotalAbsentDueToIllHealth / TotalRegistered) * 100. +* Assign a label to the new percentage variable. +VARIABLE LABELS PercentAbsentDueToIllHealth '% Children Missing School Due to Ill Health'. +* Display the result. +FORMATS PercentAbsentDueToIllHealth (F2.2). +LIST. \ No newline at end of file diff --git a/Indicators/SchoolBasedProgrammes-CRF93-SchoolAbseentism/SBP_CRF93_Abseentism_tidyverse.R b/Indicators/SchoolBasedProgrammes-CRF93-SchoolAbseentism/SBP_CRF93_Abseentism_tidyverse.R index 50c8e3f..1135d06 100644 --- a/Indicators/SchoolBasedProgrammes-CRF93-SchoolAbseentism/SBP_CRF93_Abseentism_tidyverse.R +++ b/Indicators/SchoolBasedProgrammes-CRF93-SchoolAbseentism/SBP_CRF93_Abseentism_tidyverse.R @@ -3,173 +3,58 @@ library(labelled) library(expss) #add sample data -data <- read_csv("~/GitHub/RAMResourcesScripts/Static/Nut_MDDW/Nutrition_module_MDD_W_submodule_RepeatMDDW.csv") +data <- read_csv("~/GitHub/RAMResourcesScripts/Static/SBP_CRF_63and93_Sample_Survey/SBPProcessM_module_SchoolAgeChildRoster_submodule_RepeatSchoolAgeChild.csv") -#can only download repeat csv data as zip file from moda with group names - will update this code with more elegant solution to remove group names or if you download as SPSS you can skip this step +#unfortunately you can only download repeat csv data as zip file from moda with group names - will update this code with more elegant solution to remove group names or if you download as SPSS you can skip this step #rename to remove group names -data <- data %>% rename(PWMDDWStapCer = 'Nutrition_module/MDD_W_submodule/RepeatMDDW/PWMDDWStapCer', - PWMDDWStapRoo = 'Nutrition_module/MDD_W_submodule/RepeatMDDW/PWMDDWStapRoo', - PWMDDWPulse = 'Nutrition_module/MDD_W_submodule/RepeatMDDW/PWMDDWPulse', - PWMDDWNuts = 'Nutrition_module/MDD_W_submodule/RepeatMDDW/PWMDDWNuts', - PWMDDWMilk = 'Nutrition_module/MDD_W_submodule/RepeatMDDW/PWMDDWMilk', - PWMDDWDairy = 'Nutrition_module/MDD_W_submodule/RepeatMDDW/PWMDDWDairy', - PWMDDWPrMeatO = 'Nutrition_module/MDD_W_submodule/RepeatMDDW/PWMDDWPrMeatO', - PWMDDWPrMeatF = 'Nutrition_module/MDD_W_submodule/RepeatMDDW/PWMDDWPrMeatF', - PWMDDWPrMeatPro = 'Nutrition_module/MDD_W_submodule/RepeatMDDW/PWMDDWPrMeatPro', - PWMDDWPrMeatWhite = 'Nutrition_module/MDD_W_submodule/RepeatMDDW/PWMDDWPrMeatWhite', - PWMDDWPrFish = 'Nutrition_module/MDD_W_submodule/RepeatMDDW/PWMDDWPrFish', - PWMDDWPrEgg = 'Nutrition_module/MDD_W_submodule/RepeatMDDW/PWMDDWPrEgg', - PWMDDWVegGre = 'Nutrition_module/MDD_W_submodule/RepeatMDDW/PWMDDWVegGre', - PWMDDWVegOrg = 'Nutrition_module/MDD_W_submodule/RepeatMDDW/PWMDDWVegOrg', - PWMDDWFruitOrg = 'Nutrition_module/MDD_W_submodule/RepeatMDDW/PWMDDWFruitOrg', - PWMDDWVegOth = 'Nutrition_module/MDD_W_submodule/RepeatMDDW/PWMDDWVegOth', - PWMDDWFruitOth = 'Nutrition_module/MDD_W_submodule/RepeatMDDW/PWMDDWFruitOth', - PWMDDWSnf = 'Nutrition_module/MDD_W_submodule/RepeatMDDW/PWMDDWSnf', - PWMDDWFortFoodoil = 'Nutrition_module/MDD_W_submodule/RepeatMDDW/PWMDDWFortFoodoil', - PWMDDWFortFoodwflour = 'Nutrition_module/MDD_W_submodule/RepeatMDDW/PWMDDWFortFoodwflour', - PWMDDWFortFoodmflour = 'Nutrition_module/MDD_W_submodule/RepeatMDDW/PWMDDWFortFoodmflour', - PWMDDWFortFoodrice = 'Nutrition_module/MDD_W_submodule/RepeatMDDW/PWMDDWFortFoodrice', - PWMDDWFortFooddrink = 'Nutrition_module/MDD_W_submodule/RepeatMDDW/PWMDDWFortFooddrink', - PWMDDWFortFoodother = 'Nutrition_module/MDD_W_submodule/RepeatMDDW/PWMDDWFortFoodother', - PWMDDWFortFoodother_oth = 'Nutrition_module/MDD_W_submodule/RepeatMDDW/PWMDDWFortFoodother_oth', - ) #assign variable and value labels -var_label(data$PWMDDWStapCer) <- "Foods made from grains" -var_label(data$PWMDDWStapRoo) <- "White roots and tubers or plantains" -var_label(data$PWMDDWPulse) <- "Pulses (beans, peas and lentils) " -var_label(data$PWMDDWNuts) <- "Nuts and seeds " -var_label(data$PWMDDWMilk) <- "Milk" -var_label(data$PWMDDWDairy) <- "Milk products" -var_label(data$PWMDDWPrMeatO) <- "Organ meats" -var_label(data$PWMDDWPrMeatF) <- "Red flesh meat from mammals" -var_label(data$PWMDDWPrMeatPro) <- "Processed meat" -var_label(data$PWMDDWPrMeatWhite) <- "Poultry and other white meats" -var_label(data$PWMDDWPrFish) <- "Fish and Seafood" -var_label(data$PWMDDWPrEgg) <- "Eggs from poultry or any other bird" -var_label(data$PWMDDWVegGre) <- "Dark green leafy vegetable" -var_label(data$PWMDDWVegOrg) <- "Vitamin A-rich vegetables, roots and tubers" -var_label(data$PWMDDWFruitOrg) <- "Vitamin A-rich fruits" -var_label(data$PWMDDWVegOth) <- "Other vegetables" -var_label(data$PWMDDWFruitOth) <- "Other fruits" -var_label(data$PWMDDWSnf) <- "Specialized Nutritious Foods (SNF) for women" -var_label(data$PWMDDWFortFoodoil) <- "Fortified oil" -var_label(data$PWMDDWFortFoodwflour) <- "Fortified wheat flour" -var_label(data$PWMDDWFortFoodmflour) <- "Fortified maize flour" -var_label(data$PWMDDWFortFoodrice) <- "Fortified Rice" -var_label(data$PWMDDWFortFooddrink) <- "Fortified drink" -var_label(data$PWMDDWFortFoodother) <- "Other:" -var_label(data$PWMDDWFortFoodother_oth) <- "Other: please specify: ____________" - -data <- data %>% - mutate(across(c(PWMDDWStapCer,PWMDDWStapRoo,PWMDDWPulse,PWMDDWNuts,PWMDDWMilk,PWMDDWDairy,PWMDDWPrMeatO,PWMDDWPrMeatF,PWMDDWPrMeatPro,PWMDDWPrMeatWhite,PWMDDWPrFish,PWMDDWPrEgg, - PWMDDWVegGre,PWMDDWVegOrg,PWMDDWFruitOrg,PWMDDWVegOth,PWMDDWFruitOth,PWMDDWSnf,PWMDDWFortFoodoil,PWMDDWFortFoodwflour,PWMDDWFortFoodmflour,PWMDDWFortFoodrice,PWMDDWFortFooddrink,PWMDDWFortFoodother), ~labelled(., labels = c( - "No" = 0, - "Yes" = 1 - )))) - - -#Calculate 2 MDDW indicators based on WFP guidelines https://docs.wfp.org/api/documents/WFP-0000140197/download/ pg.8 -#Standard MDDW Indicator for population based surveys - counts SNF in home group (refer to https://docs.wfp.org/api/documents/WFP-0000139484/download/ for "home group") -#WFP Modified MDDW WFP programme monitoring - counts SNF in "Meat, poultry and fish" Category - -#Standard MDDW method - in this example SNF home group will be grains -#in this example fortified foods PWMDDWFortFoodwflour,PWMDDWFortFoodmflour,PWMDDWFortFoodrice,PWMDDWFortFooddrink will also count in grains -#classifying PWMDDWFortFoodother_oth will likely involve classifying line by line -data <- data %>% mutate( - MDDW_Staples = case_when( - PWMDDWStapCer == 1 | PWMDDWStapRoo == 1 | PWMDDWSnf == 1 | PWMDDWFortFoodwflour == 1 | PWMDDWFortFoodmflour == 1 | PWMDDWFortFoodrice == 1 | PWMDDWFortFooddrink == 1 ~ 1, TRUE ~ 0), - MDDW_Pulses = case_when( - PWMDDWPulse == 1 ~ 1, TRUE ~ 0), - MDDW_NutsSeeds = case_when( - PWMDDWNuts == 1 ~ 1, TRUE ~ 0), - MDDW_Dairy = case_when( - PWMDDWDairy == 1 | PWMDDWMilk == 1 ~ 1, TRUE ~ 0), - MDDW_MeatFish = case_when( - PWMDDWPrMeatO == 1 | PWMDDWPrMeatF == 1 | PWMDDWPrMeatPro == 1 | PWMDDWPrMeatWhite == 1 | PWMDDWPrFish == 1 ~ 1, TRUE ~ 0), - MDDW_Eggs = case_when( - PWMDDWPrEgg == 1 ~ 1, TRUE ~ 0), - MDDW_LeafGreenVeg = case_when( - PWMDDWVegGre == 1 ~ 1, TRUE ~ 0), - MDDW_VitA = case_when( - PWMDDWVegOrg == 1 | PWMDDWFruitOrg == 1 ~ 1, TRUE ~ 0), - MDDW_OtherVeg = case_when( - PWMDDWVegOth == 1 ~ 1, TRUE ~ 0), - MDDW_OtherFruits = case_when( - PWMDDWFruitOth == 1 ~ 1, TRUE ~ 0) +data <- data %>% rename(PChildRegisterSchool = 'SBPProcessM_module/SchoolAgeChildRoster_submodule/RepeatSchoolAgeChild/PChildRegisterSchool', + PChildDayAttendSchool = 'SBPProcessM_module/SchoolAgeChildRoster_submodule/RepeatSchoolAgeChild/PChildDayAttendSchool', + PChildDayAbsSchool = 'SBPProcessM_module/SchoolAgeChildRoster_submodule/RepeatSchoolAgeChild/PChildDayAbsSchool', + PChildDayAbsSchoolWhy_IllHealth = 'SBPProcessM_module/SchoolAgeChildRoster_submodule/RepeatSchoolAgeChild/PChildDayAbsSchoolWhy/1', + PChildDayAbsIllHealth = 'SBPProcessM_module/SchoolAgeChildRoster_submodule/RepeatSchoolAgeChild/PChildDayAbsIllHealth', + PChildAbsIllHealth = 'SBPProcessM_module/SchoolAgeChildRoster_submodule/RepeatSchoolAgeChild/PChildAbsIllHealth' ) -#WFP MDDW method for program monitoring - SNF will count in the meats group -#in this example fortified foods PWMDDWFortFoodwflour,PWMDDWFortFoodmflour,PWMDDWFortFoodrice,PWMDDWFortFooddrink will also count in grains -#classifying PWMDDWFortFoodother_oth will likely involve classifying line by line -data <- data %>% mutate( - MDDW_Staples_wfp = case_when( - PWMDDWStapCer == 1 | PWMDDWStapRoo == 1 | PWMDDWFortFoodwflour == 1 | PWMDDWFortFoodmflour == 1 | PWMDDWFortFoodrice == 1 | PWMDDWFortFooddrink == 1 ~ 1, TRUE ~ 0), - MDDW_Pulses_wfp = case_when( - PWMDDWPulse == 1 ~ 1, TRUE ~ 0), - MDDW_NutsSeeds_wfp = case_when( - PWMDDWNuts == 1 ~ 1, TRUE ~ 0), - MDDW_Dairy_wfp = case_when( - PWMDDWDairy == 1 | PWMDDWMilk == 1 ~ 1, TRUE ~ 0), - MDDW_MeatFish_wfp = case_when( - PWMDDWPrMeatO == 1 | PWMDDWPrMeatF == 1 | PWMDDWPrMeatPro == 1 | PWMDDWPrMeatWhite == 1 | PWMDDWPrFish == 1 | PWMDDWSnf == 1 ~ 1, TRUE ~ 0), - MDDW_Eggs_wfp = case_when( - PWMDDWPrEgg == 1 ~ 1, TRUE ~ 0), - MDDW_LeafGreenVeg_wfp = case_when( - PWMDDWVegGre == 1 ~ 1, TRUE ~ 0), - MDDW_VitA_wfp = case_when( - PWMDDWVegOrg == 1 | PWMDDWFruitOrg == 1 ~ 1, TRUE ~ 0), - MDDW_OtherVeg_wfp = case_when( - PWMDDWVegOth == 1 ~ 1, TRUE ~ 0), - MDDW_OtherFruits_wfp = case_when( - PWMDDWFruitOth == 1 ~ 1, TRUE ~ 0) -) - - -#calculate MDDW variable for both methods by adding together food groups and classifying whether the woman consumed 5 or more food groups - -#Standard MDDW method where SNF is counted in grains -data <- data %>% mutate(MDDW = MDDW_Staples +MDDW_Pulses +MDDW_NutsSeeds +MDDW_Dairy +MDDW_MeatFish +MDDW_Eggs +MDDW_LeafGreenVeg +MDDW_VitA +MDDW_OtherVeg +MDDW_OtherFruits) -#count how many women consumed 5 or more groups -data <- data %>% mutate(MDDW_5 = case_when( - MDDW >= 5 ~ ">=5", TRUE ~ "<5" -)) -#WFP MDDW method for program monitoring - SNF will count in the meats group -data <- data %>% mutate(MDDW_wfp = MDDW_Staples_wfp +MDDW_Pulses_wfp +MDDW_NutsSeeds_wfp +MDDW_Dairy_wfp +MDDW_MeatFish_wfp +MDDW_Eggs_wfp +MDDW_LeafGreenVeg_wfp +MDDW_VitA_wfp +MDDW_OtherVeg_wfp +MDDW_OtherFruits_wfp) -#count how many women consumed 5 or more groups -data <- data %>% mutate(MDDW_5_wfp = case_when( - MDDW_wfp >= 5 ~ ">=5", TRUE ~ "<5" -)) - -#creates a table of the weighted percentage of Standard MDDW Method - MDDW_5 -#and providing the option to use weights if needed - -MDDW_5_table_wide <- data %>% - drop_na(MDDW_5) %>% - count(MDDW_5) %>% # if weights are needed use instead the row below - #count(MDDW_5, wt = nameofweightvariable) - mutate(Percentage = 100 * n / sum(n)) %>% - ungroup() %>% select(-n) %>% - pivot_wider(names_from = MDDW_5, - values_from = Percentage, - values_fill = 0) - -#creates a table of the weighted percentage of WFP MDDW method for program monitoring MDDW_5_wfp -#and providing the option to use weights if needed - - -MDDW_5_wfp_table_wide <- data %>% - drop_na(MDDW_5_wfp) %>% - count(MDDW_5_wfp) %>% # if weights are needed use instead the row below - #count(MDDW_5_wfp, wt = nameofweightvariable) - mutate(Percentage = 100 * n / sum(n)) %>% - ungroup() %>% select(-n) %>% - pivot_wider(names_from = MDDW_5_wfp, - values_from = Percentage, - values_fill = 0) - - - - - +var_label(data$PChildRegisterSchool) <- "Is ${PChildName} registered in school?" +var_label(data$PChildDayAttendSchool) <- "In the last 30 school days, how many days did ${PChildName} go to school?" +var_label(data$PChildDayAbsSchool) <- "In the last 30 school days, how many days was ${PChildName} absent from school?" +var_label(data$PChildDayAbsSchoolWhy_IllHealth) <- "What was the reason they missed school: Ill-health/sick" +var_label(data$PChildDayAbsIllHealth) <- "How many days was your child absent from school because of ill-health" +var_label(data$PChildAbsIllHealth) <- "Please, specify the type of illness" + +# If PChildDayAbsSchoolWhy_IllHealth and PChildRegisterSchool are not already boolean or numeric, +# you might need to convert them depending on their original format. + +data$PChildDayAbsSchoolWhy_IllHealth <- as.logical(data$PChildDayAbsSchoolWhy_IllHealth) +data$PChildRegisterSchool <- as.numeric(data$PChildRegisterSchool) + +#The percentage required for the indicator is PChildDayAbsSchoolWhy_IllHealth = TRUE / PChildRegisterSchool = 1 + +# Calculate the percentage (without weights) +# Calculate the total count of registered children and +# the count of those absent due to ill health +percentage_absent_due_to_ill_health <- data %>% + filter(PChildRegisterSchool == 1) %>% + summarise( + Total_Registered = n(), + Absent_Due_To_Ill_Health = sum(PChildDayAbsSchoolWhy_IllHealth, na.rm = TRUE), + Percentage = (Absent_Due_To_Ill_Health / Total_Registered) * 100 + ) +# View the result +print(percentage_absent_due_to_ill_health) + +# Calculate the percentage (with weights) +# Calculate the total weighted count of registered children and +# the weighted count of those absent due to ill health +percentage_absent_due_to_ill_health_wt <- data %>% + filter(PChildRegisterSchool == 1) %>% + summarise( + Total_Registered_Weighted = sum(WeightVariable, na.rm = TRUE), + Absent_Due_To_Ill_Health_Weighted = sum(WeightVariable[PChildDayAbsSchoolWhy_IllHealth], na.rm = TRUE), + Percentage = (Absent_Due_To_Ill_Health_Weighted / Total_Registered_Weighted) * 100 + ) +# View the result +print(percentage_absent_due_to_ill_health_wt) \ No newline at end of file