Dear Statalisters,
I want to concatenate two string variables. Instead of combining them using e.g. concat() I need them to be combined "piece-wise". That is, letter 1 in variable A (e.g. gender) corresponds to letter 1 in variable B (e.g.origin) and so on. Ideally, a delimiter should be added between the "pieces".
What I have:
What I need:
There might be solutions available that combine multiple loops and temp variables, but I was wondering if there is a more straightforward way to do this. Naturally, the actual number of observations is much larger and I am aware that this is not an optimal way to organize data.
Thank you and best regards
Sebastian
I want to concatenate two string variables. Instead of combining them using e.g. concat() I need them to be combined "piece-wise". That is, letter 1 in variable A (e.g. gender) corresponds to letter 1 in variable B (e.g.origin) and so on. Ideally, a delimiter should be added between the "pieces".
What I have:
Code:
clear input str20 (A B) 1111 2345 end
Code:
clear input str20 (A B C) 1111 2345 12_13_14_15 end
Thank you and best regards
Sebastian
Comment