I am using a DATA STEP where I want to write an expression for a variable in my dataset. In that expression, I want to evaluate one condition. If that condition is TRUE, then need to assign and if its FALSE then another value .
VAR1 = ?if TRUE then : if FALSE then ;
When searched on SAS help, I got to know about CASE statement where we can write a condition in an expression. But unfortunately its not working and giving some syntax error.
NOTE: The JAVA equivalent to such requirement is to use a ternary operator something like this:
VAR1= ? :
Value1 will be assigned to VAR1 if cond2 is true, and value2 in case of FALSE.
Need to find the SAS equivalent to the above.
Request you to suggest the correct syntax or any other way to achieve the above requirement.
Any help regarding this would be highly appreciated.
Thanks in Advance.
It will work, no doubt. But due to some reasons, I want to assign the value to the variable through expression only (need to use in SAS ETL) and thats where the problem is.
Off course what you have suggested is the final workaround for it; but as long as possible I want to build an expression for a variable where I can evaluate the condition and assign corresponding value.