Page 1 of 1

Asign the information of a person inside a household to another person inside the same household

Posted: September 4th, 2018, 7:37 pm
by daniedusi
How to impute the information of a persons variable inside a household to another person inside the same household?

Re: Asign the information of a person inside a household to another person inside the same household

Posted: September 4th, 2018, 7:47 pm
by josh
You have to copy the values item by item. If you have each household member as a different record, which is the most common setup for a multi-person household, then you use subscripts to refer to the different household members. So if you want to copy the values from person 3 to person 4 you would do something like:

NAME(4) = NAME(3);
AGE(4) = AGE(3);
SEX(4) = AGE(4);
etc...
where NAME, AGE and SEX are the names of the items in your dictionary.

Re: Asign the information of a person inside a household to another person inside the same household

Posted: September 4th, 2018, 8:25 pm
by daniedusi
What i wanted to do is to look in the houshold, when a person lacks some information, impute if someone has it in the household, but if no one in the household has it, impute the nearest neighbor information.

Re: Asign the information of a person inside a household to another person inside the same household

Posted: September 4th, 2018, 9:04 pm
by josh
That is fairly complicated to implement. If you are a skilled programmer you could do it by looping through the household and checking if any other member has the information you want. Looking at multiple households at once in CSPro is complicated. You would have to open the data file as an external file and use loadcase. Maybe someone else on the forum has implemented this and can give you some guidance.

The more common approach is to use a simple hotdeck technique based on a matrix that you update as you find "good" values in the data file. There is some info on that in the CSPro help: http://www.csprousers.org/help/CSPro/dy ... _deck.html. You can see examples in the CSPro examples folder under "Edits & Batch Programs/Dynamic (Hot Deck) Imputations" and "Edits & Batch Programs/Deck Arrays". The first example is the way we used to implement this imputation technique in CSPro before deck arrays were implemented. The second example performs the same imputation using the deck array feature.