Complex recoding from a list of countries to three countries visited - need help!

igrr

New Member
#1
Hello. I have a long list of countries (220), each coded 0 (not visited) or 1 (visited). For each case (respondent) only three countries are coded as 1 (visited) but those countries are not the same for every respondent. How do I create three variables (Visited country_1, Visited country_2, Visited country_3) from this list of countries? In In other words, I have the following data (e.g.)
id c1 c2 c3 c4 c5 c6 c7 c8 c9 c10
1 0 1 0 1 0 0 0 1 0 0
2 1 1 1 0 0 0 0 0 0 0

I need the following:
id vc_1 vc_2 vc_3
1 c2 (code) c4 c8
2 c1 c2 c3

Thanks for your help!
 

Karabiner

TS Contributor
#2
Use "restructure data" (VARSTOCASES), so that each respondent has 220 lines
and there are (at least) 3 rows [CORRECTION: I meant columns]:
subject id, variable name, response (0 or 1).
Then delete the lines for which response is 0 and restructure data (cases to
variables).

With kind regards

Karabiner
 
Last edited:

igrr

New Member
#3
Hi Karabiner,
Thank you for the suggestion!
Please clarify. I have 2000 respondents (id=1 to 2000) and 220 countries (c1 to c220), each coded "missing", 0 (not selected/not visited), 1 (selected/visited). What becomes "column" and what does "row" in the Data View during / after "restructure data"?
Many thanks!
 

Karabiner

TS Contributor
#4
Sorry for the mistake (see above), I meant column, not row.
First column is respondent (each respondent has 220 rows=220 countries), second column is country, third column is response (0 or 1).

With kind regards

Karabiner