I am trying to recreate code from SAS in knime. The code is a manipulation of the college_code data that contains missing values. I am trying to replace missing values with a value from another column. If there is a missing value I must also replace the column value from another column with a column value from another column. Sorry if that is confusing. Here is snippet of the SAS code I am trying to recreate.
Fill in missing college codes;
if college_code = ‘’ then do;
college_code = admin_college;
college_name = admin_name;
end;
I am trying to use rule engine but am unsure of how to execute both replacement values in the columns.
The Rule Engine only updates or creates a single column, so to adjust two values you will need to chain two Rule Engine nodes.
Since your rule is based on one of the columns that you will be updating, make sure you update that column last!
Your COLLEGE_CODE rules so far looks correct provided that it is actually MISSING (denoted by red ? in the input data table). If it is simply an empty string, you’d need to use $COLLEGE_CODE$ = "" instead. So just do the same for COLLEGE_NAME as a previous Rule Engine node and you should be good to go.
Typically in KNIME, think of a single node (especially the scripting-style nodes) as modifying a single column or flow variable. There are exceptions (e.g. multi column variants of Math Formula and String Manipulation, along with Column Expressions, Variable Expressions, Java Snippets and a few others are capable of updating more than one. Java snippets is one of the few that can update multiple columns or variables using separate logic for each within the same piece of code. Math Formula (multi) and String Manipulation (multi) allow updates of multiple columns using THE SAME logic for each, whilst the “expressions” nodes require separate logic for each column/variable but just happen to allow you to write multiple scripts within the same node… And there are the non-script nodes (such as data type conversions) that often allow you to specify multiple columns too… so now I come to think of it, very little is “typical” )