Download presentation

Presentation is loading. Please wait.

Published byAlexander Jones Modified over 3 years ago

1
MICS4 Data Processing Workshop Multiple Indicator Cluster Surveys Data Processing Workshop Built-In and User-Defined Functions

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 systems index tab –We'll discuss some of the other functions which are not documented MICS4 Data Processing Workshop

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 MICS4 Data Processing Workshop

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) MICS4 Data Processing Workshop

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 MICS4 Data Processing Workshop

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 MICS4 Data Processing Workshop

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 MICS4 Data Processing Workshop

8
The adjlba Function Purpose: adjust lower CMC bound for an event using a persons 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 Lets denote the result as rlb (resulting lower bound) MICS4 Data Processing Workshop

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 MICS4 Data Processing Workshop

10
The adjuba Function Purpose: adjust upper CMC bound for an event using a persons 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 Lets denote the result as rub (resulting upper bound) MICS4 Data Processing Workshop

11
The adjuba Function Calculates: rub = di - age*12 we make no adjustments to the persons 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

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 MICS4 Data Processing Workshop

13
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

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), dont 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 MICS4 Data Processing Workshop

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 MICS4 Data Processing Workshop

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 MICS4 Data Processing Workshop

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 MICS4 Data Processing Workshop

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 MICS4 Data Processing Workshop

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 ). MICS4 Data Processing Workshop

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 childs age in months MICS4 Data Processing Workshop

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., childs DOB and date of interview) Returns: –childs age in months if childs birth day, month, and year are valid –childs 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

25
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 well 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 MICS4 Data Processing Workshop

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 MICS4 Data Processing Workshop

28
The vdob UDF Purpose: checks if the vaccination date is after the childs date of birth Syntax: vdob(vday,vmonth,vyear) Returns: 0 if vaccination date is before the childs date of birth 1 otherwise MICS4 Data Processing Workshop

29
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

30
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

31
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

32
The alphachk UDF Syntax: alphachk(alphamask) Input: acceptable values for an alphanumeric variable –e.g., for WS7 alphamask isABCDEFXZ –e.g., for IR2 alphamask isABCXZ –e.g., for MN2 alphamask is ABCFGX Assigned before entry to the function: alphavar MICS4 Data Processing Workshop

33
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 MICS4 Data Processing Workshop

34
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

35
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

36
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

37
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

Similar presentations

OK

MICS4 Data Processing Workshop Multiple Indicator Cluster Surveys Data Processing Workshop Data Entry Applications with Logic.

MICS4 Data Processing Workshop Multiple Indicator Cluster Surveys Data Processing Workshop Data Entry Applications with Logic.

© 2017 SlidePlayer.com Inc.

All rights reserved.

Ads by Google

Ppt on story of taj mahal Ppt on placement in hrm Ppt on phase sequence checker for three phase supply Ppt on mental health act 1987 Ppt on life of amelia earhart Presentation ppt on motivation skills Ppt on effects of world war 1 Ppt on 2 dimensional figures and 3 dimensional slideshows Business intelligence microsoft ppt online Ppt on western culture vs indian culture