I need help with a SAS Base programming. How to create a new column (in this case column "BONUS") with values depending on values from another column (column column_one). Code I've tried:
if (t1.column_one=110) or (t1.column_one=111)
then put -(t1.BONUS) * 10 * 10;
else put (t1.BONUS) * 10 * 10;
The put
statement doesn't create a new column. It merely prints text to the log (or any other device you would have specified with the file
statement).
The 'table[dot]column' notation is used in SQL and does not make sense in that if
statement which is data step code.
Also, you say you want to create a new column called BONUS
, yet in your sample code you multiply instead of giving it a value. I will assume the column already exists.
A valid if condition would then be
if column_one in (110,111) then BONUS=-BONUS*100;
else BONUS=BONUS*100;