Hi all,
In the below set,
I have data for different respondents(resp_id). The concerned variable for my query is 'accompaniment' which is a multiple-select question in the survey form.
I would like to analyse the data at the respondent id level (resp_id). Corresponding to the resp_id, I want to see the consolidated 'accompaniment' variable.
i.e., I want to have all the possible accompaniment values corresponding to resp_id and generate it as a new variable, say 'consolidated_accompaniment'. The consolidated_accompaniment variable only needs to have one value for each resp_id, example: for resp_id:100109, it(consolidated_accompaniment) should be "1 3 5 12 13". I would like to generate this variable (consolidated_accompaniment) covering all resp_ids in the data. My intention is to then use the mrtab command on consolidated_accompaniment which will give me the accompaniment % at the respondent level.
input float date str6 resp_id byte activity str5 accompaniment
23233 "100109" 1 ""
23233 "100109" 13 ""
23233 "100109" 12 ""
23233 "100109" 3 "1 3 5"
23233 "100109" 9 "12"
23233 "100109" 7 ""
23233 "100109" 2 "13"
23233 "100109" 11 "1"
23233 "100109" 4 ""
23233 "100109" 5 "1"
23233 "100109" 8 ""
23233 "100109" 6 ""
23233 "100109" 10 ""
23211 "100109" 4 "1"
23211 "100109" 9 "1"
23211 "100109" 8 "1"
23211 "100109" 3 "1"
23211 "100109" 6 ""
23211 "100109" 10 ""
23211 "100109" 2 ""
23211 "100109" 5 "1"
23211 "100109" 11 ""
23211 "100109" 7 ""
23211 "100109" 1 "1"
23214 "100109" 2 "1"
23214 "100109" 16 "1"
23214 "100109" 12 "1"
23214 "100109" 13 "1"
23214 "100109" 10 ""
23214 "100109" 8 ""
23214 "100109" 5 ""
23214 "100109" 11 "1"
23214 "100109" 9 "1"
23214 "100109" 3 ""
23214 "100109" 17 ""
23214 "100109" 15 ""
23214 "100109" 1 ""
23214 "100109" 7 ""
23214 "100109" 4 ""
23214 "100109" 14 ""
23214 "100109" 6 ""
23222 "100109" 6 ""
23222 "100109" 7 ""
23222 "100109" 2 ""
23222 "100109" 3 "1"
23222 "100109" 4 ""
23222 "100109" 5 "1"
23222 "100109" 1 ""
23216 "100109" 6 ""
23216 "100109" 4 ""
23216 "100109" 3 ""
23216 "100109" 10 ""
23216 "100109" 11 "1"
23216 "100109" 1 ""
23216 "100109" 13 ""
23216 "100109" 14 "1"
23216 "100109" 12 "1"
23216 "100109" 8 "1"
23216 "100109" 2 ""
23216 "100109" 9 ""
23216 "100109" 5 ""
23216 "100109" 7 ""
23224 "100109" 9 "1"
23224 "100109" 1 ""
23224 "100109" 7 ""
23224 "100109" 8 ""
23224 "100109" 11 ""
23224 "100109" 10 "1"
23224 "100109" 3 "1"
23224 "100109" 4 ""
23224 "100109" 2 ""
23224 "100109" 6 ""
23224 "100109" 5 "1"
23221 "100109" 8 "1"
23221 "100109" 6 ""
23221 "100109" 2 ""
23221 "100109" 1 ""
23221 "100109" 5 ""
23221 "100109" 9 "1"
23221 "100109" 4 ""
23221 "100109" 3 ""
23221 "100109" 7 ""
23233 "100212" 9 ""
23233 "100212" 5 "1"
23233 "100212" 8 "1"
23233 "100212" 4 ""
23233 "100212" 11 ""
23233 "100212" 10 "1"
23233 "100212" 6 ""
23233 "100212" 1 ""
23233 "100212" 7 ""
23233 "100212" 2 ""
23233 "100212" 3 "1"
23222 "100212" 10 "1"
23222 "100212" 3 "1"
23222 "100212" 8 "1"
23222 "100212" 9 ""
23222 "100212" 12 ""
23222 "100212" 6 ""
23222 "100212" 5 ""
end
format %d date
[/CODE]
In the below set,
I have data for different respondents(resp_id). The concerned variable for my query is 'accompaniment' which is a multiple-select question in the survey form.
I would like to analyse the data at the respondent id level (resp_id). Corresponding to the resp_id, I want to see the consolidated 'accompaniment' variable.
i.e., I want to have all the possible accompaniment values corresponding to resp_id and generate it as a new variable, say 'consolidated_accompaniment'. The consolidated_accompaniment variable only needs to have one value for each resp_id, example: for resp_id:100109, it(consolidated_accompaniment) should be "1 3 5 12 13". I would like to generate this variable (consolidated_accompaniment) covering all resp_ids in the data. My intention is to then use the mrtab command on consolidated_accompaniment which will give me the accompaniment % at the respondent level.
input float date str6 resp_id byte activity str5 accompaniment
23233 "100109" 1 ""
23233 "100109" 13 ""
23233 "100109" 12 ""
23233 "100109" 3 "1 3 5"
23233 "100109" 9 "12"
23233 "100109" 7 ""
23233 "100109" 2 "13"
23233 "100109" 11 "1"
23233 "100109" 4 ""
23233 "100109" 5 "1"
23233 "100109" 8 ""
23233 "100109" 6 ""
23233 "100109" 10 ""
23211 "100109" 4 "1"
23211 "100109" 9 "1"
23211 "100109" 8 "1"
23211 "100109" 3 "1"
23211 "100109" 6 ""
23211 "100109" 10 ""
23211 "100109" 2 ""
23211 "100109" 5 "1"
23211 "100109" 11 ""
23211 "100109" 7 ""
23211 "100109" 1 "1"
23214 "100109" 2 "1"
23214 "100109" 16 "1"
23214 "100109" 12 "1"
23214 "100109" 13 "1"
23214 "100109" 10 ""
23214 "100109" 8 ""
23214 "100109" 5 ""
23214 "100109" 11 "1"
23214 "100109" 9 "1"
23214 "100109" 3 ""
23214 "100109" 17 ""
23214 "100109" 15 ""
23214 "100109" 1 ""
23214 "100109" 7 ""
23214 "100109" 4 ""
23214 "100109" 14 ""
23214 "100109" 6 ""
23222 "100109" 6 ""
23222 "100109" 7 ""
23222 "100109" 2 ""
23222 "100109" 3 "1"
23222 "100109" 4 ""
23222 "100109" 5 "1"
23222 "100109" 1 ""
23216 "100109" 6 ""
23216 "100109" 4 ""
23216 "100109" 3 ""
23216 "100109" 10 ""
23216 "100109" 11 "1"
23216 "100109" 1 ""
23216 "100109" 13 ""
23216 "100109" 14 "1"
23216 "100109" 12 "1"
23216 "100109" 8 "1"
23216 "100109" 2 ""
23216 "100109" 9 ""
23216 "100109" 5 ""
23216 "100109" 7 ""
23224 "100109" 9 "1"
23224 "100109" 1 ""
23224 "100109" 7 ""
23224 "100109" 8 ""
23224 "100109" 11 ""
23224 "100109" 10 "1"
23224 "100109" 3 "1"
23224 "100109" 4 ""
23224 "100109" 2 ""
23224 "100109" 6 ""
23224 "100109" 5 "1"
23221 "100109" 8 "1"
23221 "100109" 6 ""
23221 "100109" 2 ""
23221 "100109" 1 ""
23221 "100109" 5 ""
23221 "100109" 9 "1"
23221 "100109" 4 ""
23221 "100109" 3 ""
23221 "100109" 7 ""
23233 "100212" 9 ""
23233 "100212" 5 "1"
23233 "100212" 8 "1"
23233 "100212" 4 ""
23233 "100212" 11 ""
23233 "100212" 10 "1"
23233 "100212" 6 ""
23233 "100212" 1 ""
23233 "100212" 7 ""
23233 "100212" 2 ""
23233 "100212" 3 "1"
23222 "100212" 10 "1"
23222 "100212" 3 "1"
23222 "100212" 8 "1"
23222 "100212" 9 ""
23222 "100212" 12 ""
23222 "100212" 6 ""
23222 "100212" 5 ""
end
format %d date
[/CODE]
Comment