*******Z score with and without for wrong measurement position adjustment********** use IAKR52FL.dta,clear gen mdate = mdy(hw18, hw17, hw19) // Calculate measurement date in days gen bdate = mdy(b1, hw16, b2) if hw16 <= 31 // Calculate birth date in days replace bdate = mdy(b1, 15, b2) if hw16 > 31 // adjustment for missing birth date gen age_days = (mdate-bdate) // Calculate age (in days) replace age_days = 15 if (hw16 > 31) & (b1==hw18 & b2==hw19) & mdate > bdate // adjsutment for birth month and year is same as measurement birth and year and mdate > bdate (error) gen age = age_days/30.4375 // Calculate age in months with days expressed as decimals gen hw2_2 = hw2/10 if hw13==0 // Converting weight in Kg and keeping only measured weight gen hw3_2 = hw3/10 if hw13==0 // Converting height in cm and keeping only measured weight gen hw3_adj= hw3_2 //for adjustment based on measurement position based on lying or standing replace hw3_adj= hw3_2 + .7 if hw15 ==2 & age_days<731 // adjusting children of age below 731 days who are measured in standing position (as WHO guideline) replace hw3_adj= hw3_2 - .7 if hw15 ==1 & age_days>=731 // adjusting children above age 731 days who are measured in lying gen hw70_new= hw70/100 if hw70 <9000 // converting posted Z-Score in decimal places zscore06 if hw13==0, a(age) s(b4) h(hw3_2) w(hw2_2) // using without adjustment in height according to measurement position ren haz06 haz06_old ren waz06 waz06_old ren whz06 whz06_old ren bmiz06 bmi06_old zscore06 if hw13==0, a(age) s(b4) h(hw3_adj) w(hw2_2) // using earlier command in Stata ********************Analysis based on adjustment for wrong measurement position and flagged Z_score********* gen bad_measure=0 if hw13==0 // only for those children who are measured replace bad_measure =1 if ((hw15==1 & age_days >=731) | (hw15==2 & age_days <731)) & bad_measure==0 label define bad_measure 0"Correct" 1"Wrong" label values bad_measure bad_measure gen flagged = 0 if hw70 <9000 & hw13==0 // creating variable for analyzing flagged values replace flagged =1 if hw70 >9000 & hw13==0 label define flagged 0"non-flagged" 1"flagged" label values flagged flagged gen match1 =1 if abs(haz06_old - hw70_new ) <.1 & hw13==0 // for matching with without adjustment replace match1 =0 if abs(haz06_old - hw70_new ) >=.1 & hw13==0 label define match 0"not matching" 1"matching" label values match match gen match =1 if abs(haz06 - hw70_new ) <.1 & hw13==0 // for matching with adjustment replace match =0 if abs(haz06 - hw70_new ) >=.1 & hw13==0 label values match match tab flagged match1 tab flagged match tab hw15 bad_measure if flagged==0 & match==0