MICS4 Data Processing Workshop Multiple Indicator Cluster Surveys Data Processing Workshop Built-In...
-
Upload
alexander-jones -
Category
Documents
-
view
227 -
download
0
Transcript of MICS4 Data Processing Workshop Multiple Indicator Cluster Surveys Data Processing Workshop Built-In...
![Page 1: MICS4 Data Processing Workshop Multiple Indicator Cluster Surveys Data Processing Workshop Built-In and User-Defined Functions.](https://reader036.fdocuments.us/reader036/viewer/2022062303/5514b0ab55034640138b509e/html5/thumbnails/1.jpg)
MICS4 Data Processing Workshop
Multiple Indicator Cluster SurveysData Processing Workshop
Built-In and User-Defined Functions
![Page 2: MICS4 Data Processing Workshop Multiple Indicator Cluster Surveys Data Processing Workshop Built-In and User-Defined Functions.](https://reader036.fdocuments.us/reader036/viewer/2022062303/5514b0ab55034640138b509e/html5/thumbnails/2.jpg)
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
MICS4 Data Processing Workshop
![Page 3: MICS4 Data Processing Workshop Multiple Indicator Cluster Surveys Data Processing Workshop Built-In and User-Defined Functions.](https://reader036.fdocuments.us/reader036/viewer/2022062303/5514b0ab55034640138b509e/html5/thumbnails/3.jpg)
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
MICS4 Data Processing Workshop
![Page 4: MICS4 Data Processing Workshop Multiple Indicator Cluster Surveys Data Processing Workshop Built-In and User-Defined Functions.](https://reader036.fdocuments.us/reader036/viewer/2022062303/5514b0ab55034640138b509e/html5/thumbnails/4.jpg)
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)
MICS4 Data Processing Workshop
![Page 5: MICS4 Data Processing Workshop Multiple Indicator Cluster Surveys Data Processing Workshop Built-In and User-Defined Functions.](https://reader036.fdocuments.us/reader036/viewer/2022062303/5514b0ab55034640138b509e/html5/thumbnails/5.jpg)
The setlb FunctionPurpose: 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
MICS4 Data Processing Workshop
![Page 6: MICS4 Data Processing Workshop Multiple Indicator Cluster Surveys Data Processing Workshop Built-In and User-Defined Functions.](https://reader036.fdocuments.us/reader036/viewer/2022062303/5514b0ab55034640138b509e/html5/thumbnails/6.jpg)
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
MICS4 Data Processing Workshop
![Page 7: MICS4 Data Processing Workshop Multiple Indicator Cluster Surveys Data Processing Workshop Built-In and User-Defined Functions.](https://reader036.fdocuments.us/reader036/viewer/2022062303/5514b0ab55034640138b509e/html5/thumbnails/7.jpg)
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
MICS4 Data Processing Workshop
![Page 8: MICS4 Data Processing Workshop Multiple Indicator Cluster Surveys Data Processing Workshop Built-In and User-Defined Functions.](https://reader036.fdocuments.us/reader036/viewer/2022062303/5514b0ab55034640138b509e/html5/thumbnails/8.jpg)
The adjlba FunctionPurpose: 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)
MICS4 Data Processing Workshop
![Page 9: MICS4 Data Processing Workshop Multiple Indicator Cluster Surveys Data Processing Workshop Built-In and User-Defined Functions.](https://reader036.fdocuments.us/reader036/viewer/2022062303/5514b0ab55034640138b509e/html5/thumbnails/9.jpg)
The adjlba FunctionCalculates:
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
MICS4 Data Processing Workshop
![Page 10: MICS4 Data Processing Workshop Multiple Indicator Cluster Surveys Data Processing Workshop Built-In and User-Defined Functions.](https://reader036.fdocuments.us/reader036/viewer/2022062303/5514b0ab55034640138b509e/html5/thumbnails/10.jpg)
The adjuba FunctionPurpose: 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)
MICS4 Data Processing Workshop
![Page 11: MICS4 Data Processing Workshop Multiple Indicator Cluster Surveys Data Processing Workshop Built-In and User-Defined Functions.](https://reader036.fdocuments.us/reader036/viewer/2022062303/5514b0ab55034640138b509e/html5/thumbnails/11.jpg)
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
MICS4 Data Processing Workshop
![Page 12: MICS4 Data Processing Workshop Multiple Indicator Cluster Surveys Data Processing Workshop Built-In and User-Defined Functions.](https://reader036.fdocuments.us/reader036/viewer/2022062303/5514b0ab55034640138b509e/html5/thumbnails/12.jpg)
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
MICS4 Data Processing Workshop
![Page 13: MICS4 Data Processing Workshop Multiple Indicator Cluster Surveys Data Processing Workshop Built-In and User-Defined Functions.](https://reader036.fdocuments.us/reader036/viewer/2022062303/5514b0ab55034640138b509e/html5/thumbnails/13.jpg)
User-Defined Function (UDF)
• UDFs are defined in the PROC GLOBAL block
• There are 23 UDFs in the data entry application
• These functions do not need to be modified (except function vdvalid), but they do need to be understood
MICS4 Data Processing Workshop
![Page 14: MICS4 Data Processing Workshop Multiple Indicator Cluster Surveys Data Processing Workshop Built-In and User-Defined Functions.](https://reader036.fdocuments.us/reader036/viewer/2022062303/5514b0ab55034640138b509e/html5/thumbnails/14.jpg)
Data Checking UDFsThere 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
![Page 15: MICS4 Data Processing Workshop Multiple Indicator Cluster Surveys Data Processing Workshop Built-In and User-Defined Functions.](https://reader036.fdocuments.us/reader036/viewer/2022062303/5514b0ab55034640138b509e/html5/thumbnails/15.jpg)
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
MICS4 Data Processing Workshop
![Page 16: MICS4 Data Processing Workshop Multiple Indicator Cluster Surveys Data Processing Workshop Built-In and User-Defined Functions.](https://reader036.fdocuments.us/reader036/viewer/2022062303/5514b0ab55034640138b509e/html5/thumbnails/16.jpg)
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
MICS4 Data Processing Workshop
![Page 17: MICS4 Data Processing Workshop Multiple Indicator Cluster Surveys Data Processing Workshop Built-In and User-Defined Functions.](https://reader036.fdocuments.us/reader036/viewer/2022062303/5514b0ab55034640138b509e/html5/thumbnails/17.jpg)
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
![Page 18: MICS4 Data Processing Workshop Multiple Indicator Cluster Surveys Data Processing Workshop Built-In and User-Defined Functions.](https://reader036.fdocuments.us/reader036/viewer/2022062303/5514b0ab55034640138b509e/html5/thumbnails/18.jpg)
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
![Page 19: MICS4 Data Processing Workshop Multiple Indicator Cluster Surveys Data Processing Workshop Built-In and User-Defined Functions.](https://reader036.fdocuments.us/reader036/viewer/2022062303/5514b0ab55034640138b509e/html5/thumbnails/19.jpg)
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
MICS4 Data Processing Workshop
![Page 20: MICS4 Data Processing Workshop Multiple Indicator Cluster Surveys Data Processing Workshop Built-In and User-Defined Functions.](https://reader036.fdocuments.us/reader036/viewer/2022062303/5514b0ab55034640138b509e/html5/thumbnails/20.jpg)
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
MICS4 Data Processing Workshop
![Page 21: MICS4 Data Processing Workshop Multiple Indicator Cluster Surveys Data Processing Workshop Built-In and User-Defined Functions.](https://reader036.fdocuments.us/reader036/viewer/2022062303/5514b0ab55034640138b509e/html5/thumbnails/21.jpg)
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
MICS4 Data Processing Workshop
![Page 22: MICS4 Data Processing Workshop Multiple Indicator Cluster Surveys Data Processing Workshop Built-In and User-Defined Functions.](https://reader036.fdocuments.us/reader036/viewer/2022062303/5514b0ab55034640138b509e/html5/thumbnails/22.jpg)
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).
MICS4 Data Processing Workshop
![Page 23: MICS4 Data Processing Workshop Multiple Indicator Cluster Surveys Data Processing Workshop Built-In and User-Defined Functions.](https://reader036.fdocuments.us/reader036/viewer/2022062303/5514b0ab55034640138b509e/html5/thumbnails/23.jpg)
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
MICS4 Data Processing Workshop
![Page 24: MICS4 Data Processing Workshop Multiple Indicator Cluster Surveys Data Processing Workshop Built-In and User-Defined Functions.](https://reader036.fdocuments.us/reader036/viewer/2022062303/5514b0ab55034640138b509e/html5/thumbnails/24.jpg)
The agemth UDFPurpose: 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
MICS4 Data Processing Workshop
![Page 25: MICS4 Data Processing Workshop Multiple Indicator Cluster Surveys Data Processing Workshop Built-In and User-Defined Functions.](https://reader036.fdocuments.us/reader036/viewer/2022062303/5514b0ab55034640138b509e/html5/thumbnails/25.jpg)
Vaccination UDFs
• There are three UDFs in the data entry application that check the validity of the vaccination date: vdvalid, vdoi, and vdob
• There are two more UDFs in the editing program that check the ordering of vaccination dates, which we’ll discuss now: vseq and vmatch
![Page 26: MICS4 Data Processing Workshop Multiple Indicator Cluster Surveys Data Processing Workshop Built-In and User-Defined Functions.](https://reader036.fdocuments.us/reader036/viewer/2022062303/5514b0ab55034640138b509e/html5/thumbnails/26.jpg)
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
MICS4 Data Processing Workshop
![Page 27: MICS4 Data Processing Workshop Multiple Indicator Cluster Surveys Data Processing Workshop Built-In and User-Defined Functions.](https://reader036.fdocuments.us/reader036/viewer/2022062303/5514b0ab55034640138b509e/html5/thumbnails/27.jpg)
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
MICS4 Data Processing Workshop
![Page 28: MICS4 Data Processing Workshop Multiple Indicator Cluster Surveys Data Processing Workshop Built-In and User-Defined Functions.](https://reader036.fdocuments.us/reader036/viewer/2022062303/5514b0ab55034640138b509e/html5/thumbnails/28.jpg)
The vdob UDF
• Purpose: checks if the vaccination date is after the child’s date of birth
• Syntax: vdob(vday,vmonth,vyear)• Returns:
0 if vaccination date is before the child’s date of birth
1 otherwise
MICS4 Data Processing Workshop
![Page 29: MICS4 Data Processing Workshop Multiple Indicator Cluster Surveys Data Processing Workshop Built-In and User-Defined Functions.](https://reader036.fdocuments.us/reader036/viewer/2022062303/5514b0ab55034640138b509e/html5/thumbnails/29.jpg)
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
MICS4 Data Processing Workshop
![Page 30: MICS4 Data Processing Workshop Multiple Indicator Cluster Surveys Data Processing Workshop Built-In and User-Defined Functions.](https://reader036.fdocuments.us/reader036/viewer/2022062303/5514b0ab55034640138b509e/html5/thumbnails/30.jpg)
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
MICS4 Data Processing Workshop
![Page 31: MICS4 Data Processing Workshop Multiple Indicator Cluster Surveys Data Processing Workshop Built-In and User-Defined Functions.](https://reader036.fdocuments.us/reader036/viewer/2022062303/5514b0ab55034640138b509e/html5/thumbnails/31.jpg)
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
MICS4 Data Processing Workshop
![Page 32: MICS4 Data Processing Workshop Multiple Indicator Cluster Surveys Data Processing Workshop Built-In and User-Defined Functions.](https://reader036.fdocuments.us/reader036/viewer/2022062303/5514b0ab55034640138b509e/html5/thumbnails/32.jpg)
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
MICS4 Data Processing Workshop
![Page 33: MICS4 Data Processing Workshop Multiple Indicator Cluster Surveys Data Processing Workshop Built-In and User-Defined Functions.](https://reader036.fdocuments.us/reader036/viewer/2022062303/5514b0ab55034640138b509e/html5/thumbnails/33.jpg)
The alphachk UDFActions:
• 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 ”
MICS4 Data Processing Workshop
![Page 34: MICS4 Data Processing Workshop Multiple Indicator Cluster Surveys Data Processing Workshop Built-In and User-Defined Functions.](https://reader036.fdocuments.us/reader036/viewer/2022062303/5514b0ab55034640138b509e/html5/thumbnails/34.jpg)
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
MICS4 Data Processing Workshop
![Page 35: MICS4 Data Processing Workshop Multiple Indicator Cluster Surveys Data Processing Workshop Built-In and User-Defined Functions.](https://reader036.fdocuments.us/reader036/viewer/2022062303/5514b0ab55034640138b509e/html5/thumbnails/35.jpg)
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
MICS4 Data Processing Workshop
![Page 36: MICS4 Data Processing Workshop Multiple Indicator Cluster Surveys Data Processing Workshop Built-In and User-Defined Functions.](https://reader036.fdocuments.us/reader036/viewer/2022062303/5514b0ab55034640138b509e/html5/thumbnails/36.jpg)
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.
MICS4 Data Processing Workshop
![Page 37: MICS4 Data Processing Workshop Multiple Indicator Cluster Surveys Data Processing Workshop Built-In and User-Defined Functions.](https://reader036.fdocuments.us/reader036/viewer/2022062303/5514b0ab55034640138b509e/html5/thumbnails/37.jpg)
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
MICS4 Data Processing Workshop