Hi @ll,@ll,
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 "-".
Example:
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.
Table_0: Table_1:
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
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:
catx('-',match,"42");
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".
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.