Two questions:
1. My main question is, Can I create a code short cut to replace the string variables within a set code.
I am analysing survey data. Questions where multiple responses are allowed, the survey system exports all the responses in one cell separated by a comma. I've split these in Stata using.

However, I have to replace the string variable in the code each time by hand. Is there a way to code this more simply or less copy past. I have a list of the string values (they are a fixed list from the survey).
Is it possible, or worth it, to arrange these up as a sequence within one cell eg. [0,1,1,1,0,0,0,1,0,1,1], where somewhere the string values are encoded to each position within the set (I hope this makes sense).
Many thanks,
Dr. DB
1. My main question is, Can I create a code short cut to replace the string variables within a set code.
I am analysing survey data. Questions where multiple responses are allowed, the survey system exports all the responses in one cell separated by a comma. I've split these in Stata using.
Now to count/convert each instance I've started with this code.
'split variable, p(,)'
This has essentially counted the instances into a numeric value in a new column.
generate variable2=1 if splitvarialble1=="stringvalueA" | splitvarialble2=="stringvalueA" | splitvarialble3=="stringvalueA" etc...
generate variable3=1 if splitvarialble1=="stringvalueB" | splitvarialble2=="stringvalueB" | splitvarialble3=="stringvalueB" etc...
generate variable4=1 if splitvarialble1=="stringvalueC" | splitvarialble2=="stringvalueC" | splitvarialble3=="stringvalueC" etc...
However, I have to replace the string variable in the code each time by hand. Is there a way to code this more simply or less copy past. I have a list of the string values (they are a fixed list from the survey).
Is it possible, or worth it, to arrange these up as a sequence within one cell eg. [0,1,1,1,0,0,0,1,0,1,1], where somewhere the string values are encoded to each position within the set (I hope this makes sense).
Many thanks,
Dr. DB
Comment