Hello, I'm hoping someone can help me with this. I'm working with two 6-digit string variables and, from these, need to produce a third/final string variable. For example, my data set looks like this:
where the non-zero characters in STRING1 represent the correct values but not the correct character placement, and the non-zero characters in STRING2 represent the correct placement but not the correct values. What I need is a third variable that replaces the non-zero values in STRING2 with the non-zero values from STRING1 in the positions found in STRING2. In other words:
Thanks in advance.
Code:
input id str6 string1 str6 string2 1 "100000" "400000" 2 "020000" "400000" 3 "020100" "040003" 4 "000022" "003300" end
- When ID==1, the third (new) string would read "1000000"
- When ID==2, the third (new) string would read "2000000"
- When ID==3, the third (new) string would read "0200001"
- When ID==4, the third (new) string would read "0022000"
Thanks in advance.
Comment