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".
Don't miss out on SAS Innovate - Register now for the FREE Livestream!
Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.
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.