08-11-2016 05:03 AM - edited 08-11-2016 05:04 AM
how can I append a value to an existing value? I want to look up a value from a column_1 in a column_2 and everytime there's a match it should write a specific value to a column_3. The tricky part (for me right now) is that, if an observation already got a specific value in column_3, the new match should append at the end of the first match with a "-".
In the final Table_1, I could use the "Block_done_with_scan" variable to mark all values in V1 and V2 as belonging to specific code 42.
V1 | V2 V1 | V2 | Match | Block_done_with_scan
1 | 2 1 | 2 | 42-42 | 42
2 | 1 2 | 1 | 42 | 42
2 | 2 2 | 2 | 42-42 | 42
08-11-2016 05:12 AM
Well, I am not following your text there very well, but the easiest way to append a value to an existing one is to use the string cat functions, e.g:
The above is an eample of the catx() function. The first parameter shows the delimiter, thats the character(s) which will divide each of the following elements. After that is the elements. Now if match is empty you will just get "42", no delimier as there is only one value, if match has something then it will go match + "-" + "42".