Hot decks in CSPro are implemented using
Array objects. First, you must declare the array under the
PROC GLOBAL section. Then you need to set the initial values for the hot deck array. There are two ways to initialize and maintain arrays in CSPro:
Once the array has been declared and initialized, you need to add logic to check each occurrence of the variable you wish to impute using the hot deck. If the value of the variable is valid, update the hot deck by assigning this value to the appropriate cell in the array. If the value is invalid, set the value of the variable based on the corresponding cell in the hot deck. A simple usage could be:
This example uses the traditional
inline method of maintaining hot decks.
PROC GLOBAL
Array HD_Age_SexRel(2, 8); // hot deck for age, uses sex & relationship as indices
PROC AGE
if AGE = notappl then
// if the value for age is invalid:
// assign a valid value from the hot deck based on sex and relationship
impute(AGE, HD_Age_SexRel(SEX, RELATIONSHIP));
else
// otherwise:
// update the value of the hot deck with the good value found
HD_Age_SexRel(SEX, RELATIONSHIP) = AGE;
endif;
This example uses the
save array method of maintaining hot decks.
PROC GLOBAL
// the hot deck for age uses the sex & relationship value sets
// to define the array dimensions
Array HD_Age_SexRel(SEX_VS, REL_VS) save;
PROC AGE
if AGE = notappl then
// if the value for age is invalid:
// assign a valid value from the hot deck based on sex and relationship
impute(AGE, HD_Age_SexRel()); // no parameters needed for HD_Age_SexRel
else
// otherwise:
// update the value of the hot deck with the good value found
HD_Age_SexRel() = AGE; // CSPro uses the current value of sex & rel as the indices
endif;
When an age is missing during the data file's processing, we will use a value from the array HD_Age_SexRel; when an age is valid, we will "refresh" the age for the person using the current sex and relationship codes as indices into the array.