Multiple Indicator Cluster Surveys Data Processing Workshop

# Multiple Indicator Cluster Surveys Data Processing Workshop

## Multiple Indicator Cluster Surveys Data Processing Workshop

- - - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - - -
##### Presentation Transcript

1. Multiple Indicator Cluster SurveysData Processing Workshop Built-In and User-Defined Functions MICS Data Processing Workshop

2. Built-In Functions • CSPro has a wide range of built-in functions • They are not accessible for modification • Most built-in functions are well-documented in the help system • You can see a list of these functions by searching on “Alphabetical List of Statements and Functions” within the help system’s index tab • We'll discuss some of the other functions which are not documented

3. Century Month Code (CMC) Makes date calculations easier to handle • January 1900 = CMC 1 • December 1900 = CMC 12 • January 1901 = CMC 13 • April 2000 = CMC 1204 • April 2001 = CMC 1216 • CMC = (Year-1900)*12 + Month

4. The cmcode Function Purpose: calculate the CMC of a month/year Syntax: cmcode(month,year) Returns: • if month and year valid: CMC of the month/year provided • if month or year is invalid: 9999(invalid means month or year is equal to DK, missing)

5. The setlb Function Purpose: calculate the lower CMC bound for an event Syntax: setlb(month,year,minimum) Returns: • if month and year valid: CMC of month/year • if month invalid: CMC of 1/year • if year invalid: minimum

6. The setub Function Purpose: calculate the upper CMC bound for an event Syntax: setub(month,year,maximum) Returns: • if month and year valid: CMC of month/year • if month invalid: CMC of 12/year • if year invalid: maximum

7. Example of setlb and setub Suppose: WB1M = 98; WB1Y = 1962; Using setlb and setub, set local variables dobLB & dobUB (DOB lower/upper bound) as follows: dobLB = setlb(WB1M,WB1Y,0);  745 dobUB = setub(WB1M,WB1Y,9999);  756

8. The adjlba Function Purpose: adjust lower CMC bound for an event using a person’s age; i.e., it calculates a minimum date of birth Syntax: adjlba(lcmc,ucmc,di,di,age) Arguments: • lcmc is the lower CMC bound of an event • ucmc is the upper CMC bound of event • di is the CMC date of interview • Let’s denote the result as rlb (resulting lower bound)

9. The adjlba Function Calculates: rlb = di – age*12 – 11 we subtract 11 (months), because we assume the person just had their birthday and is therefore at the “bottom-end” of their age, with 11 more months to go before having another birthday Returns: • if rlb in lcmc:ucmc rlb • if rlb < lcmc lcmc • if rlb > ucmc -1 Example: woman born 98/1962; her age=47; date of interview = Aug 2009 adjlba (745,756,1316,1316,47)  741; however, this is below the given lcmc, and so rlb will be assigned 745

10. The adjuba Function Purpose: adjust upper CMC bound for an event using a person’s age; i.e., it calculates a maximum date of birth Syntax: adjuba(lcmc,ucmc,di,di,age) Arguments: • lcmc is the lower CMC bound of event • ucmc is the upper CMC bound of event • di is the CMC date of interview • Let’s denote the result as rub (resulting upper bound)

11. The adjuba Function Calculates: rub = di - age*12 we make no adjustments to the person’s age, as we assume they are at the “top-end” of their age, with a birthday looming later this month or in the next month Returns: if rub in lcmc:ucmc rub if rub > ucmc ucmc if rub < lcmc -1 Example: woman born 98/1962; her age=47; date of interview = Aug 2009 adjuba (745,756,1316,1316,47)  752; since this is lower than the given ucmc, rlb will be assigned 752

12. Example of adjlba and adjuba • Suppose • WB1M = 98, WB1Y = 1975 and WB2 = 34 years dobLB = setlb(WB1M,WB1Y,0);  901 dobUB = setub(WB1M,WB1Y,0);  912 • DOI is 06/2009 so di = 1314 • Using the lower and upper ranges in the adjxba functions below, we find that we can narrow the range of possible cmc birth dates to 901-906 rlb=adjlba(dobLB,dobUB,di,di,WB2)901 rub=adjuba(dobLB,dobUB,di,di,WB2)906

13. User-Defined Function (UDF) • UDFs are defined in the PROC GLOBAL block • These functions do not need to be modified (except functionvdvalid), but they do need to be understood

14. Data Checking UDFs There are four UDFs that assist with executing arithmetic operations: valid—checks if the value is not a special value, i.e., other (96), inconsistent (97), don’t know (98), or missing (99) NAtoZero—if a question has been skipped (assigning a value of ‘not applicable’ to that question) or is missing, this function will return 0 (zero), so that the question can be used in arithmetic equations notEq—a value-added <> command badspecial—ensures that Unit/Number questions are consistent with one another

15. The valid UDF Purpose: ensures that a variable has a valid value Syntax: valid (xvar) Returns: 1  if value of xvar is not “special” (i.e., is not equal to notappl) and ≤ 95 0  otherwise

16. The NAtoZero UDF Purpose: permits one to use variables that could be “not applicable” in arithmetic equations Syntax: NAtoZero(xvar) Returns: 0  if value of xvar is not applicable  value of xvar otherwise

17. The notEq UDF Purpose: A value-added <> check. dvar is passed thru the NAtoZero function first before the <> test is made. Syntax: notEq(xvar,dvar) Returns: 1  if xvar <> NAtoZero (dvar) 0  otherwise

18. The badspecial UDF Purpose: Ensures that the Unit response is consistent with the Number response Syntax: badspecial(units,number) Returns: 1  if there is a problem, i.e., if U = 9 & N <= 90 or U <> 9 & N in 90:98 or U > 1 & N = 0 0  otherwise

19. Birth History UDFs • There are three UDFs that concern the birth history • ValidYr – like valid except for 4 digit years • AfterInt – checks if a date is after the date of interview • ndjlba – like adjlba with a slight change

20. The validyr UDF Purpose: ensures that a year variable has a valid year value Syntax: validyr (xvar) Returns: 1  if value of xvar is not “special” (i.e., is not equal to notappl or missing) and ≤ 9995 0  otherwise

21. The AfterInt UDF Purpose: ensures that a date is before the date of interview Syntax: AfterInt (vcheckm, vchecky) Returns: 1  if vchecky > year of interview (WM6Y) or, (if vchecky = year of interview (WM6Y) and vcheckm > month of interview (WM6M) ) 0  otherwise

22. The ndjlba UDF Purpose: adjusts the lower bound a pair of century month code values for a date, based on the age reported (modified version of adjlba). Syntax: ndjlba(lcmc,ucmc,di,di,age) Returns: Same as for adjlba, but it avoids the possibility of producing a CMC that would imply the imputation of an age that is 1 year higher (possible with adjlba).

23. Anthropometry UDFs • There are seven UDFs that concern anthropometry • The first six of these will not be discussed • The seventh is named agemth • It calculates a child’s age in months

24. The agemth UDF Purpose: calculates most accurate age in months possible (used for anthropometry) Syntax: agemth(bd,bm,by,id,im,iy) (i.e., child’s DOB and date of interview) Returns: • child’s age in months if child’s birth day, month, and year are valid • child’s age in months using 15 as day if only birth month and year are valid • 9999 if only birth year is valid

25. Vaccination UDFs • There are four UDFs in the data entry application that check the validity of the vaccination date: vdvalid, vdoi, vdobandvacgiven • There are two more UDFs in the editing program that check the ordering of vaccination dates, which we’ll discuss now: vseq and vmatch

26. The vdvalid UDF • Purpose: checks if the vaccination date is valid (look for !!! in the logic to adjust dates per your interview period) • Syntax: vdvalid(vday,vmonth,vyear) • Returns: 0  if vaccination date is valid 1  otherwise

27. The vdoi UDF • Purpose: checks if the vaccination is not after the date of interview • Syntax: vdoi(vday,vmonth,vyear) • Returns: 0  if vaccination date before date of interview 1  otherwise

28. The vdob UDF • Purpose: checks if the vaccination is not before the date of birth • Syntax: vdob(vday,vmonth,vyear) • Returns: 0  if vaccination date after date of birth 1  otherwise

29. The vacgivenUDF • Purpose: checks if the vaccination is given or not • Syntax: vacgiven(xvar) • Returns: 1  if vaccination is given 0  otherwise

30. The vseq UDF (Editing Only!) • Purpose: checks that sequential vaccinations are in the correct order (e.g., that Polio 1 is before Polio 2) • Syntax: vseq(v1d,v1m,v1y,v2d,v2m,v2y) • Returns: 0  if vaccination 1 was given before vaccination 2 (i.e., everything is ok) 1  otherwise

31. The vmatch UDF (Editing Only!) • Purpose: check if vaccinations commonly given on the same date (e.g., Polio and DPT) were in fact given on the same date • Syntax: vmatch(v1d,v1m,v1y,v2d,v2m,v2y) • Returns: 0  if vaccinations given on the same date 1  otherwise

32. The endmess UDF • Syntax: endmess() • Action: in add mode displays options 1 “Review Questionnaire” 2 “Next Questionnaire” • Returns: 1  if data entry operator selects “Review Questionnaire” option from menu 0  otherwise

33. The alphachk UDF • Syntax: alphachk(alphamask) • Input: acceptable values for an alphanumeric variable • e.g., for WS7 alphamask is “ABCDEFXZ” • e.g., for IR2 alphamask is “ABCXZ” • e.g., for MN2 alphamask is “ABCFGX” • Assigned before entry to the function: alphavar

34. The alphachk UDF Actions: • check responses in alphavar are in alphamask • check responses in alphavar are in alphabetical order • ensure if ? is in alphavar, then it is the only response in alphavar • places each response in alphavar in the location defined by its subitem • e.g., for WS7, “ACEF” becomes “A C EF ”

35. Net Roster UDFs There are three UDFs that concern the Insecticide Treated Nets (ITN) Roster Clear_labels – Clears array of labels used by SetNet SetNet – Prepares array of possible persons sleeping under net for display CheckNet – Checks validity of responses for persons sleeping under nets

36. The clear_labels UDF Syntax: clear_labels() Action: blanks out all entries in two arrays: Labels = “” Codes = notappl Used in preparation for setnet Returns: nothing

37. The setnet UDF Syntax: setnet(xvarname, curnet) Action: Creates a list of household members and their line numbers that have not already been reported as sleeping under a net. Returns: Nothing, but Arrays Codes and Labels are set to the line numbers of the household members not yet reported.

38. The checknet UDF Syntax: checknet(xvar, xvarname, curnet) Action: Checks the line number (xvar) given as sleeping under a net with the list of household members and ensures that they have not already been listed as sleeping under a net. Returns: Error message number  if an error was found 0  otherwise